-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README & Refactor source code (#1)
* Update README & Add the 'availableimages' function * Refactor source code * Add header
- Loading branch information
Showing
5 changed files
with
119 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,14 @@ | ||
module GeoArtifacts | ||
# ----------------------------------------------------------------- | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ----------------------------------------------------------------- | ||
|
||
using GeoIO | ||
using Meshes | ||
using Unitful | ||
using GeoTables | ||
module GeoArtifacts | ||
|
||
using GADM | ||
using INMET | ||
using GeoStatsImages | ||
|
||
""" | ||
gadm(country, subregions...; depth=0, ϵ=nothing, | ||
min=3, max=typemax(Int), maxiter=10, fix=true) | ||
(Down)load GADM table using `GADM.get` and convert | ||
the `geometry` column to Meshes.jl geometries. | ||
The `depth` option can be used to return tables for subregions | ||
at a given depth starting from the given region specification. | ||
The options `ϵ`, `min`, `max` and `maxiter` are forwarded to the | ||
`decimate` function from Meshes.jl to reduce the number of vertices. | ||
The option `fix` can be used to fix orientation and degeneracy | ||
issues with polygons. | ||
""" | ||
function gadm(country, subregions...; depth=0, ϵ=nothing, min=3, max=typemax(Int), maxiter=10, fix=true, kwargs...) | ||
table = GADM.get(country, subregions...; depth, kwargs...) | ||
geotable = GeoIO.asgeotable(table, fix) | ||
dom = domain(geotable) | ||
newdom = decimate(dom, ϵ; min, max, maxiter) | ||
georef(values(geotable), newdom) | ||
end | ||
|
||
""" | ||
inmetstations(kind=:automatic) | ||
Return INMET stations of given kind. There are two kinds of stations: `:automatic` and `:manual`. | ||
""" | ||
function inmetstations(kind=:automatic) | ||
df = INMET.stations(kind) | ||
names = propertynames(df) | ||
cnames = [:VL_LONGITUDE, :VL_LATITUDE, :VL_ALTITUDE] | ||
fnames = setdiff(names, cnames) | ||
feats = df[:, fnames] | ||
coords = ustrip.(df[:, cnames]) | ||
points = map(eachrow(coords)) do row | ||
x, y, z = row | ||
Point(x, y, z) | ||
end | ||
georef(feats, PointSet(points)) | ||
end | ||
include("gadm.jl") | ||
include("inmet.jl") | ||
|
||
export gadm, geostatsimage, inmetstations | ||
export GADM, INMET, GeoStatsImages | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ----------------------------------------------------------------- | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ----------------------------------------------------------------- | ||
|
||
module GADM | ||
|
||
using GeoIO | ||
using Meshes | ||
using GeoTables | ||
|
||
import GADM as GADMData | ||
|
||
""" | ||
GADM.get(country, subregions...; depth=0, ϵ=nothing, | ||
min=3, max=typemax(Int), maxiter=10, fix=true) | ||
(Down)load GADM table and convert the `geometry` column to Meshes.jl geometries. | ||
The `depth` option can be used to return tables for subregions | ||
at a given depth starting from the given region specification. | ||
The options `ϵ`, `min`, `max` and `maxiter` are forwarded to the | ||
`decimate` function from Meshes.jl to reduce the number of vertices. | ||
The option `fix` can be used to fix orientation and degeneracy | ||
issues with polygons. | ||
""" | ||
function get(country, subregions...; depth=0, ϵ=nothing, min=3, max=typemax(Int), maxiter=10, fix=true, kwargs...) | ||
table = GADMData.get(country, subregions...; depth, kwargs...) | ||
geotable = GeoIO.asgeotable(table, fix) | ||
dom = domain(geotable) | ||
newdom = decimate(dom, ϵ; min, max, maxiter) | ||
georef(values(geotable), newdom) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# ----------------------------------------------------------------- | ||
# Licensed under the MIT License. See LICENSE in the project root. | ||
# ----------------------------------------------------------------- | ||
|
||
module INMET | ||
|
||
using Meshes | ||
using Unitful | ||
using GeoTables | ||
|
||
import INMET as INMETData | ||
|
||
""" | ||
INMET.stations(kind=:automatic) | ||
Return INMET stations of given kind. There are two kinds of stations: `:automatic` and `:manual`. | ||
""" | ||
function stations(kind=:automatic) | ||
df = INMETData.stations(kind) | ||
names = propertynames(df) | ||
cnames = [:VL_LONGITUDE, :VL_LATITUDE, :VL_ALTITUDE] | ||
fnames = setdiff(names, cnames) | ||
feats = df[:, fnames] | ||
coords = ustrip.(df[:, cnames]) | ||
points = map(eachrow(coords)) do row | ||
x, y, z = row | ||
Point(x, y, z) | ||
end | ||
georef(feats, PointSet(points)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters