Skip to content

Commit

Permalink
Merge pull request #5 from JuliaEarth/natural-earth
Browse files Browse the repository at this point in the history
Add NaturalEarth backend
  • Loading branch information
eliascarv committed May 9, 2024
2 parents 44039df + daa6be3 commit 0940c34
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GeoStatsImages = "7cd16168-b42c-5e7d-a585-4f59d326662d"
GeoTables = "e502b557-6362-48c1-8219-d30d308dcdb0"
INMET = "1fb021e9-9ab7-46c1-8a23-23f3c2783cf7"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
NaturalEarth = "436b0209-26ab-4e65-94a9-6526d86fea76"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
Expand All @@ -19,5 +20,6 @@ GeoStatsImages = "1.1"
GeoTables = "1.19"
INMET = "1.0"
Meshes = "0.42"
NaturalEarth = "0.1"
Unitful = "1.17"
julia = "1.9"
1 change: 1 addition & 0 deletions src/GeoArtifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module GeoArtifacts
include("image.jl")
include("gadm.jl")
include("inmet.jl")
include("naturalearth.jl")

export GADM, INMET

Expand Down
28 changes: 28 additions & 0 deletions src/naturalearth.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -----------------------------------------------------------------
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

using GeoIO

import NaturalEarth as NE

"""
GeoArtifacts.naturalearth(name::String; fix=true, version = v"5.1.2")
GeoArtifacts.naturalearth(name::String, scale::Int; fix=true, version = v"5.1.2")
Load a NaturalEarth dataset as a `GeoTable`.
The `name` should not include the `ne_` prefix, and if providing a `scale`
should also not include a scale. No suffix should be added.
The option `fix` can be used to fix orientation and degeneracy
issues with polygons.
# Examples
```julia
GeoArtifacts.naturalearth("admin_0_countries", 110)
GeoArtifacts.naturalearth("110m_admin_0_countries")
```
"""
naturalearth(args...; fix=true, kwargs...) = GeoIO.asgeotable(NE.naturalearth(args...; kwargs...), fix)
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ using Test
@test gtb.geometry isa PointSet
@test embeddim(gtb.geometry) == 3
end

@testset "NaturalEarth.jl" begin
gtb = GeoArtifacts.naturalearth("admin_0_countries", 110)
@test gtb.geometry isa GeometrySet
@test embeddim(gtb.geometry) == 2

gtb = GeoArtifacts.naturalearth("110m_admin_0_countries")
@test gtb.geometry isa GeometrySet
@test embeddim(gtb.geometry) == 2
end
end

0 comments on commit 0940c34

Please sign in to comment.