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

GDALRasterSource resolutions should not change after resample #3123

Closed
echeipesh opened this issue Oct 14, 2019 · 2 comments
Closed

GDALRasterSource resolutions should not change after resample #3123

echeipesh opened this issue Oct 14, 2019 · 2 comments
Assignees
Labels

Comments

@echeipesh
Copy link
Contributor

gdal > console
[info] Starting scala interpreter...
Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_211).
Type in expressions for evaluation. Or try :help.

scala> import geotrellis.raster.gdal._
import geotrellis.raster.gdal._

scala> import geotrellis.raster.io.geotiff.{AutoHigherResolution, OverviewStrategy}
import geotrellis.raster.io.geotiff.{AutoHigherResolution, OverviewStrategy}

scala> import geotrellis.raster.resample._
import geotrellis.raster.resample._

scala> val rs = GDALRasterSource("/Users/eugene/proj/geotrellis/raster/data/vlm/aspect-tiled.tif")
rs: geotrellis.raster.gdal.GDALRasterSource = GDALRasterSource(/Users/eugene/proj/geotrellis/raster/data/vlm/aspect-tiled.tif,GDALWarpOptions(-of VRT -ovr AUTO))

scala> rs.resolutions
res0: List[geotrellis.raster.CellSize] = List(CellSize(20.0,20.0), CellSize(40.0,39.94082840236686), CellSize(79.7872340425532,79.88165680473372))

scala> val resampled = rs.resample(TargetCellSize(CellSize(25,25)), NearestNeighbor, AutoHigherResolution)
resampled: geotrellis.raster.RasterSource = GDALRasterSource(/Users/eugene/proj/geotrellis/raster/data/vlm/aspect-tiled.tif,GDALWarpOptions(-of VRT -tap -tr 25.0 25.0 -ovr AUTO -te 630000.0 215000.0 645000.0 228500.0))

scala> resampled.resolutions
res5: List[geotrellis.raster.CellSize] = List(CellSize(50.0,50.0), CellSize(100.0,100.0))

The purpose of RasterSource.resolutions method is to inform at what resolution it is safe to read the data to minimize IO.

This conflicts with default behavior of GDAL Warp DataSource which attempts to preserve the number of overviews using the same pixel decimation from the base raster. So in the example above it attempts to preserve 1:2 and 1:4 overviews when the "resample to CellSize(25,25)" is applied to base raster layer.

@pomadchin
Copy link
Member

Will make a separate PR with it probably, to decompose it from #3124

@pomadchin
Copy link
Member

Closed in #3214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants