Skip to content

Commit

Permalink
Fix Create submodules for naturalearth and image
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed May 20, 2024
1 parent 57b3f7a commit 727a24d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 27 deletions.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[![Build Status](https://github.com/JuliaEarth/GeoArtifacts.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaEarth/GeoArtifacts.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/JuliaEarth/GeoArtifacts.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaEarth/GeoArtifacts.jl)

Julia package for loading geospatial artifacts such as datasets from different sources.
GeoArtifacts.jl provides geospatial artifacts (e.g., datasets) from different sources. It is used in the book
[*Geospatial Data Science with Julia*](https://juliaearth.github.io/geospatial-data-science-with-julia).

## Usage

Expand Down Expand Up @@ -42,7 +43,21 @@ julia> GADM.get("BRA", depth=1)
#### NaturalEarth
```julia
NaturalEarth.get(identifier)
julia> NaturalEarth.get("admin_0_countries", 110)
177×169 GeoTable over 177 GeometrySet{2,Float32}
┌─────────────┬───────────────┬───────────────────────┬─────────────┬─────────────┬─────────────┬────────────────────────────────────
│ FCLASS_IL │ CONTINENT │ NAME_FA │ WB_A3 │ ADM0_A3_WB │ FCLASS_SE │ NAME_RU
│ Categorical │ Categorical │ Categorical │ Categorical │ Categorical │ Categorical │ Categorical
│ [NoUnits] │ [NoUnits] │ [NoUnits] │ [NoUnits] │ [NoUnits] │ [NoUnits] │ [NoUnits]
├─────────────┼───────────────┼───────────────────────┼─────────────┼─────────────┼─────────────┼────────────────────────────────────
missing │ Oceania │ فیجی │ FJI │ -99missing │ Фиджи
missing │ Africa │ تانزانیا │ TZA │ -99missing │ Танзания
missing │ Africa │ صحرای غربی │ -99-99missing │ Западная Сахара
missing │ North America │ کانادا │ CAN │ -99missing │ Канада
missing │ North America │ ایالات متحده آمریکا │ USA │ -99missing │ США
└─────────────┴───────────────┴───────────────────────┴─────────────┴─────────────┴─────────────┴────────────────────────────────────
162 columns and 172 rows omitted
```
#### INMET
Expand Down Expand Up @@ -74,5 +89,19 @@ julia> INMET.stations()
### GeoStatsImages
```julia
julia> GeoStatsImages.get(identifier)
julia> GeoStatsImages.get("WalkerLake")
160000×2 GeoTable over 400×400 CartesianGrid{2,Float64}
┌────────────┬───────────────────────────────────────────┐
│ Z │ geometry │
│ Continuous │ Quadrangle │
│ [NoUnits] │ │
├────────────┼───────────────────────────────────────────┤
0.256614Quadrangle((0.0, 0.0), ..., (0.0, 1.0)) │
0.260752Quadrangle((1.0, 0.0), ..., (1.0, 1.0)) │
0.26127Quadrangle((2.0, 0.0), ..., (2.0, 1.0)) │
0.24452Quadrangle((3.0, 0.0), ..., (3.0, 1.0)) │
0.220545Quadrangle((4.0, 0.0), ..., (4.0, 1.0)) │
└────────────┴───────────────────────────────────────────┘
159995 rows omitted
```
6 changes: 3 additions & 3 deletions src/GeoArtifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

module GeoArtifacts

include("image.jl")
include("gadm.jl")
include("inmet.jl")
include("naturalearth.jl")
include("inmet.jl")
include("geostatsimages.jl")

export GADM, INMET
export GADM, NaturalEarth, INMET, GeoStatsImages

end
17 changes: 16 additions & 1 deletion src/image.jl → src/geostatsimages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

module GeoStatsImages

using GeoStatsImages

image(name) = geostatsimage(name)
"""
GeoStatsImages.get(name)
Load image with given `name` from geostatistics literature.
# Examples
```julia
GeoStatsImages.get("WalkerLake")
```
"""
get(name) = geostatsimage(name)

end
14 changes: 9 additions & 5 deletions src/naturalearth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# Licensed under the MIT License. See LICENSE in the project root.
# -----------------------------------------------------------------

module NaturalEarth

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")
NaturalEarth.get(name::String; fix=true, version = v"5.1.2")
NaturalEarth.get(name::String, scale::Int; fix=true, version = v"5.1.2")
Load a NaturalEarth dataset as a `GeoTable`.
Expand All @@ -21,8 +23,10 @@ issues with polygons.
# Examples
```julia
GeoArtifacts.naturalearth("admin_0_countries", 110)
GeoArtifacts.naturalearth("110m_admin_0_countries")
NaturalEarth.get("admin_0_countries", 110)
NaturalEarth.get("110m_admin_0_countries")
```
"""
naturalearth(args...; fix=true, kwargs...) = GeoIO.asgeotable(NE.naturalearth(args...; kwargs...), fix)
get(args...; fix=true, kwargs...) = GeoIO.asgeotable(NE.naturalearth(args...; kwargs...), fix)

end
30 changes: 15 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ using Meshes
using Test

@testset "GeoArtifacts.jl" begin
@testset "GeoStatsImages.jl" begin
gtb = GeoArtifacts.image("Strebelle")
@test names(gtb) == ["facies", "geometry"]
end

@testset "GADM.jl" begin
@testset "GADM" begin
gtb = GADM.get("SVN", depth=1)
@test length(gtb.geometry) == 12

Expand All @@ -19,7 +14,17 @@ using Test
@test length(gtb.geometry) == 7
end

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

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

@testset "INMET" begin
# automatic stations
gtb = INMET.stations()
@test all(isequal("Automatica"), gtb.TP_ESTACAO)
Expand All @@ -33,13 +38,8 @@ using Test
@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
@testset "GeoStatsImages" begin
gtb = GeoStatsImages.get("Strebelle")
@test names(gtb) == ["facies", "geometry"]
end
end

0 comments on commit 727a24d

Please sign in to comment.