Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade GeoStatsBase compat and fix interpolation. #147

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
fail-fast: false
matrix:
version:
- "1.6"
- "1"
- "1.9"
- "nightly"
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
with:
version: "1.6"
version: "1.9"
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.3] - 2023-10-14
- Update GeoStatsBase compat bounds and fix interpolation
- Drop Julia 1.6 (LTS), now requires 1.9

## [0.8.2] - 2023-05-10
- Fix backwards compatible constructors for metadata, so the old constructor `GeoArray(A, f, crs)` still works.

Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeoArrays"
uuid = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.8.3"
version = "0.8.4"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand All @@ -23,9 +23,9 @@ DataAPI = "1"
Extents = "0.1"
GeoFormatTypes = "0.4"
GeoInterface = "1"
GeoStatsBase = "0.21 - 0.30, 0.33"
GeoStatsBase = "0.37, 0.38"
IterTools = "1"
PrecompileTools = "1"
RecipesBase = "0.7, 0.8, 1.0"
StaticArrays = "0.12, 1.0"
julia = "1.6 - 1"
julia = "1.9"
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ makedocs(
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://evetion.github.io/GeoArrays.jl",
assets=String[]
assets=String[],
repolink="https://github.com/evetion/GeoArrays.jl"
),
pages=[
"Home" => "index.md",
Expand Down
File renamed without changes
File renamed without changes
12 changes: 9 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ julia> plot(ga)
julia> plot(ga, band=2)
```

![example plot](../img/RGB.byte.png)
![example plot](img/RGB.byte.png)

Note that for larger GeoArrays, only a sample of the data is plotted for performance.
By default the sample size is twice figure size. You can control this factor by calling `plot(ga, scalefactor=2)`,
Expand All @@ -211,7 +211,7 @@ AffineMap([300.0379266750948 0.0; 0.0 -300.041782729805], [161692.54740834387, 2

julia> plot(ga_sub)
```
![example plot](../img/RGB.byte.subset.png)
![example plot](img/RGB.byte.subset.png)

### Profile
You can sample the values along a line in a GeoArray with `profile(ga, linestring)`. The linestring can be any geometry that supports [GeoInterface.jl](https://github.com/JuliaGeo/GeoInterface.jl/).
Expand All @@ -220,6 +220,12 @@ You can sample the values along a line in a GeoArray with `profile(ga, linestrin
## Alternatives
GeoArrays.jl was written to quickly save a geospatial Array to disk. Its functionality mimics `rasterio` in Python. If one requires more features---such as rasterization or zonal stats---which also work on NetCDF files, [Rasters.jl](https://github.com/rafaqz/Rasters.jl/) is a good alternative. Its functionality is more like `(rio)xarray` in Python.

## Index
# API
```@autodocs
Modules = [GeoArrays]
```

# Index
```@index
```

8 changes: 6 additions & 2 deletions src/interpolate.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using GeoStatsBase

"""Interpolate missing values in GeoArray."""
"""
fill!(ga::GeoArray, solver::EstimationSolver, band=1)

Replace missing values in GeoArray `ga` using `solver` from the GeoStats ecosystem.
"""
function fill!(ga::GeoArray, solver::T, band=1) where {T<:EstimationSolver}
data = @view ga.A[:, :, band]
m = ismissing.(data)
sum(m) == 0 && return ga
cds = collect(coords(ga))
problemdata = georef(
problemdata = GeoStatsBase.georef(
(; band=@view data[.!m]),
@view cds[.!m]
)
Expand Down
2 changes: 1 addition & 1 deletion test/test_crs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const GFT = GeoFormatTypes
merc_proj_string = "+proj=merc +lat_ts=56.5 +ellps=GRS80"

epsg_nl_wkt = "PROJCS[\"Amersfoort / RD New\",GEOGCS[\"Amersfoort\",DATUM[\"Amersfoort\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"6289\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4289\"]],PROJECTION[\"Oblique_Stereographic\"],PARAMETER[\"latitude_of_origin\",52.1561605555556],PARAMETER[\"central_meridian\",5.38763888888889],PARAMETER[\"scale_factor\",0.9999079],PARAMETER[\"false_easting\",155000],PARAMETER[\"false_northing\",463000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"28992\"]]"
merc_wkt = "PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"Unknown based on GRS80 ellipsoid\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Mercator_2SP\"],PARAMETER[\"standard_parallel_1\",56.5],PARAMETER[\"central_meridian\",0],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]"
merc_wkt = "PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"Unknown based on GRS 1980 ellipsoid\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Mercator_2SP\"],PARAMETER[\"standard_parallel_1\",56.5],PARAMETER[\"central_meridian\",0],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]"
wgs84_wkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"

@testset "Set CRS on GeoArray" begin
Expand Down
6 changes: 3 additions & 3 deletions test/test_interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ using GeoStatsSolvers
ga = GeoArray(Array{Union{Missing,Float64}}(rand(10, 10, 1)), GeoArrays.geotransform_to_affine(SVector(0.0, 1.0, 0.0, 0.0, 0.0, 1.0)), "")
ga.A[2, 2, 1] = missing
@test count(ismissing, ga.A) == 1
GeoArrays.fill!(ga, Kriging())
GeoArrays.fill!(ga, KrigingSolver())
@test count(ismissing, ga.A) == 0
end
@testset "Regular Grid interpolation with negative spacing" begin
ga = GeoArray(Array{Union{Missing,Float64}}(rand(10, 10, 1)), GeoArrays.geotransform_to_affine(SVector(0.0, 1.0, 0.0, 0.0, 0.0, -1.0)), "")
ga.A[2, 2, 1] = missing
@test count(ismissing, ga.A) == 1
GeoArrays.fill!(ga, Kriging())
GeoArrays.fill!(ga, KrigingSolver())
@test count(ismissing, ga.A) == 0
end
@testset "Irregular Grid interpolation" begin
ga = GeoArray(Array{Union{Missing,Float64}}(rand(10, 10, 1)), GeoArrays.geotransform_to_affine(SVector(0.0, 1.0, 1.0, 0.0, 0.0, 1.0)), "")
ga.A[2, 2, 1] = missing
@test count(ismissing, ga.A) == 1
GeoArrays.fill!(ga, IDW())
GeoArrays.fill!(ga, IDWSolver())
@test count(ismissing, ga.A) == 0
end
end