@@ -28,6 +28,7 @@ import geotrellis.vector.Extent
2828import org .locationtech .rasterframes ._
2929import org .apache .spark .sql .functions ._
3030import org .locationtech .rasterframes .TestEnvironment
31+ import org .locationtech .rasterframes .datasource .raster ._
3132
3233/**
3334 * @since 1/14/18
@@ -186,7 +187,7 @@ class GeoTiffDataSourceSpec
186187 }
187188
188189 it(" should write GeoTIFF without layer" ) {
189- import org . locationtech . rasterframes . datasource . raster . _
190+
190191 val pr = col(" proj_raster_b0" )
191192 val rf = spark.read.raster.withBandIndexes(0 , 1 , 2 ).load(rgbCogSamplePath.toASCIIString)
192193
@@ -219,6 +220,23 @@ class GeoTiffDataSourceSpec
219220 }
220221 }
221222
223+ it(" should produce the correct subregion" ) {
224+ import spark .implicits ._
225+ val rf = SinglebandGeoTiff (TestData .singlebandCogPath.getPath)
226+ .projectedRaster.toLayer(128 , 128 ).withExtent()
227+
228+ val out = Paths .get(" target" , " example3-geotiff.tif" )
229+ logger.info(s " Writing to $out" )
230+
231+ val bitOfLayer = rf.filter($" spatial_key.col" === 0 && $" spatial_key.row" === 0 )
232+ val expectedExtent = bitOfLayer.select($" extent" .as[Extent ]).first()
233+ bitOfLayer.write.geotiff.save(out.toString)
234+
235+ val result = SinglebandGeoTiff (out.toString)
236+ result.tile.dimensions should be (128 , 128 )
237+ result.extent should be (expectedExtent)
238+ }
239+
222240 def s (band : Int ): String =
223241 s " https://modis-pds.s3.amazonaws.com/MCD43A4.006/11/08/2019059/ " +
224242 s " MCD43A4.A2019059.h11v08.006.2019072203257_B0 ${band}.TIF "
0 commit comments