Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
✨ new file for resampling
Browse files Browse the repository at this point in the history
  • Loading branch information
gottacatchenall committed Oct 26, 2021
1 parent 86e04a2 commit 3c60d16
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SimpleSDMLayers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ export WithinRadius, RandomSelection, SurfaceRangeEnvelope
include(joinpath("operations", "coarsen.jl"))
include(joinpath("operations", "sliding.jl"))
include(joinpath("operations", "mask.jl"))
include(joinpath("operations", "resample.jl"))
include(joinpath("operations", "rescale.jl"))
include(joinpath("operations", "mosaic.jl"))
export coarsen, slidingwindow, mask, rescale!, rescale, mosaic
export coarsen, slidingwindow, mask, rescale!, rescale, mosaic, resample

include(joinpath("recipes", "recipes.jl"))
export bivariate
Expand Down
34 changes: 34 additions & 0 deletions src/operations/resample.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function SimpleSDMLayers.resample(x)
GeoData.resample(x)
end

"""
Code from GeoData.jl
warp(A::AbstractGeoArray, flags::Dict)
function warp(A::AbstractGeoArray, flags::Dict)
odims = otherdims(A, (X, Y, Band))
if length(odims) > 0
# Handle dimensions other than X, Y, Band
slices = slice(A, odims)
warped = map(A -> _warp(A, flags), slices)
return combine(warped, odims)
else
return _warp(A, flags)
end
end
warp(st::AbstractGeoStack, flags::Dict) = map(A -> warp(A, flags), st)
function _warp(A::AbstractGeoArray, flags::Dict)
flagvect = reduce([flags...]; init=[]) do acc, (key, val)
append!(acc, String[_asflag(key), _stringvect(val)...])
end
AG.Dataset(A) do dataset
AG.gdalwarp([dataset], flagvect) do warped
_maybe_permute_from_gdal(read(GeoArray(warped)), dims(A))
end
end
end
"""

0 comments on commit 3c60d16

Please sign in to comment.