Skip to content

Commit

Permalink
Merge pull request #6 from JuliaEarth/interpolate
Browse files Browse the repository at this point in the history
Add more constructors for `Interpolate` and `InterpolateNeighbors`
  • Loading branch information
juliohm authored Sep 20, 2023
2 parents 337877a + ce5abb1 commit 113f48a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/interpneighbors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
Interpolate geospatial data on given `domain` using geostatistical models
`model₁`, ..., `modelₙ` for variables `vars₁`, ..., `varsₙ`.
InterpolateNeighbors(domain, model=IDW(); [parameters])
Interpolate geospatial data on given `domain` using geostatistical `model` for all variables.
Unlike [`Interpolate`](@ref), this transform uses neighbor search methods to
fit geostatistical models at each interpolation location with a reduced number
of measurements.
Expand Down Expand Up @@ -69,7 +73,8 @@ InterpolateNeighbors(
prob
)

InterpolateNeighbors(domain::Domain; kwargs...) = InterpolateNeighbors(domain, [AllSpec()], [IDW()]; kwargs...)
InterpolateNeighbors(domain::Domain, model::GeoStatsModel=IDW(); kwargs...) =
InterpolateNeighbors(domain, [AllSpec()], [model]; kwargs...)

InterpolateNeighbors(domain::Domain, pairs::Pair{<:Any,<:GeoStatsModel}...; kwargs...) =
InterpolateNeighbors(domain, colspec.(first.(pairs)), last.(pairs); kwargs...)
Expand Down
7 changes: 6 additions & 1 deletion src/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
Interpolate geospatial data on given `domain` using geostatistical models
`model₁`, ..., `modelₙ` for variables `vars₁`, ..., `varsₙ`.
Interpolate(domain, model=IDW(); [parameters])
Interpolate geospatial data on given `domain` using geostatistical `model` for all variables.
## Parameters
* `point` - Perform interpolation on point support (default to `true`)
Expand All @@ -26,7 +30,8 @@ end
Interpolate(domain::Domain, colspecs, models; point=true, prob=false) =
Interpolate(domain, collect(ColSpec, colspecs), collect(GeoStatsModel, models), point, prob)

Interpolate(domain::Domain; kwargs...) = Interpolate(domain, [AllSpec()], [IDW()]; kwargs...)
Interpolate(domain::Domain, model::GeoStatsModel=IDW(); kwargs...) =
Interpolate(domain, [AllSpec()], [model]; kwargs...)

Interpolate(domain::Domain, pairs::Pair{<:Any,<:GeoStatsModel}...; kwargs...) =
Interpolate(domain, colspec.(first.(pairs)), last.(pairs); kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion test/interpneighbors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pset = PointSet(rand(Point2, 3))
gtb = georef((a=[1, 2, 3], b=[4, 5, 6]), pset)
ngtb = gtb |> InterpolateNeighbors(pset, maxneighbors=3)
ngtb = gtb |> InterpolateNeighbors(pset, IDW(), maxneighbors=3)
@test ngtb.a == gtb.a
@test ngtb.b == gtb.b
@test ngtb.geometry == pset
Expand Down
2 changes: 1 addition & 1 deletion test/interpolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pset = PointSet(rand(Point2, 3))
gtb = georef((a=[1, 2, 3], b=[4, 5, 6]), pset)
ngtb = gtb |> Interpolate(pset)
ngtb = gtb |> Interpolate(pset, IDW())
@test ngtb.a == gtb.a
@test ngtb.b == gtb.b
@test ngtb.geometry == pset
Expand Down

0 comments on commit 113f48a

Please sign in to comment.