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

Pass baseTiff to new RasterSource on GeoTiffResampleRasterSource.reproject/convert #3485

Merged
merged 1 commit into from
Oct 1, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Accumulo update up to 1.10.x [#3476](https://github.com/locationtech/geotrellis/pull/3476)
- Fixed Extent.translate [#3480](https://github.com/locationtech/geotrellis/pull/3480)
- liftCompletableFuture function fix [#3483](https://github.com/locationtech/geotrellis/pull/3483)
- Pass baseTiff to new RasterSource on GeoTiffResampleRasterSource.reproject/convert [#3485](https://github.com/locationtech/geotrellis/pull/3485)

## [3.6.3] - 2022-07-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class GeoTiffReprojectRasterSource(
GeoTiffReprojectRasterSource(dataPath, crs, resampleTarget, method, strategy, targetCellType = targetCellType, baseTiff = Some(tiff))

def convert(targetCellType: TargetCellType): RasterSource =
GeoTiffReprojectRasterSource(dataPath, crs, resampleTarget, resampleMethod, strategy, targetCellType = Some(targetCellType))
GeoTiffReprojectRasterSource(dataPath, crs, resampleTarget, resampleMethod, strategy, targetCellType = Some(targetCellType), baseTiff = Some(tiff))

override def toString: String = s"GeoTiffReprojectRasterSource(${dataPath.value}, $crs, $resampleTarget, $resampleMethod)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GeoTiffResampleRasterSource(
tiff.getClosestOverview(gridExtent.cellSize, strategy)

def reprojection(targetCRS: CRS, resampleTarget: ResampleTarget = DefaultTarget, method: ResampleMethod = ResampleMethod.DEFAULT, strategy: OverviewStrategy = OverviewStrategy.DEFAULT): GeoTiffReprojectRasterSource =
new GeoTiffReprojectRasterSource(dataPath, targetCRS, resampleTarget, method, strategy, targetCellType = targetCellType) {
new GeoTiffReprojectRasterSource(dataPath, targetCRS, resampleTarget, method, strategy, targetCellType = targetCellType, baseTiff = Some(tiff)) {
override lazy val gridExtent: GridExtent[Long] = {
val reprojectedRasterExtent =
ReprojectRasterExtent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import geotrellis.raster.io.geotiff.reader.GeoTiffReader
import geotrellis.raster.resample._
import geotrellis.raster.testkit._
import geotrellis.vector._
import geotrellis.proj4.WebMercator

import org.scalatest.GivenWhenThen
import org.scalatest.funspec.AnyFunSpec
Expand Down Expand Up @@ -85,6 +86,14 @@ class GeoTiffRasterSourceSpec extends AnyFunSpec with RasterMatchers with GivenW
}
}

it("should preserve baseTiff on resample/reproject") {
val resampled = source.resample((source.cols * 0.95).toInt , (source.rows * 0.95).toInt, NearestNeighbor)
val reprojected = resampled.reproject(WebMercator)
source.tiff shouldBe theSameInstanceAs (reprojected.asInstanceOf[GeoTiffReprojectRasterSource].tiff)
val converted = reprojected.convert(UShortCellType)
source.tiff shouldBe theSameInstanceAs (converted.asInstanceOf[GeoTiffReprojectRasterSource].tiff)
}

it("resampleToRegion should produce an expected raster") {
val uri = baseGeoTiffPath("vlm/lc8-utm-1.tif")
val urie = baseGeoTiffPath("vlm/lc8-utm-1-re.tif")
Expand Down