Skip to content

GDALRasterSource resolutions should not change after resample #3123

Closed

Description

@echeipesh
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.

Activity

  1. self-assigned this
    on Oct 14, 2019
  2. pomadchin commented on Oct 15, 2019

    @pomadchin
    Member

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

  3. pomadchin commented on Mar 30, 2020

    @pomadchin
    Member

    Closed in #3214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions