Skip to content

Commit 8a9de2c

Browse files
pass the geometry.extent to sparseStitch #413
This avoids stitching the entire layoutdefinition, which creates a lot of empty tiles.
1 parent c161c6c commit 8a9de2c

File tree

1 file changed

+4
-3
lines changed
  • openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff

1 file changed

+4
-3
lines changed

openeo-geotrellis/src/main/scala/org/openeo/geotrellis/geotiff/package.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ package object geotiff {
835835

836836
val layout = rdd.metadata.layout
837837
val crs = rdd.metadata.crs
838-
val geotiffResults = rdd.flatMap {
838+
val groupedRDD = rdd.flatMap {
839839
case (key, tile) => features.filter { case (_, extent) =>
840840
val tileBounds = layout.mapTransform(extent)
841841

@@ -844,7 +844,8 @@ package object geotiff {
844844
((name, extent), (key, tile))
845845
}
846846
}.groupByKey()
847-
.map { case ((tileId, extent), tiles) =>
847+
val geotiffResults = groupedRDD.map {
848+
case ((tileId, extent), tiles) =>
848849
// Each executor writes to a unique folder to avoid conflicts:
849850
val executorAttemptDirectory = createExecutorAttemptDirectory(Path.of(path).getParent)
850851
val filePath = executorAttemptDirectory + "/" + newFilePath(Path.of(path).getFileName.toString, tileId)
@@ -869,7 +870,7 @@ package object geotiff {
869870
croppedExtent: Option[Extent], cropDimensions: Option[java.util.ArrayList[Int]],
870871
compression: Compression, formatOptions: Option[GTiffOptions] = None
871872
): GeoTiffResultObject = {
872-
val raster: Raster[MultibandTile] = ContextSeq(tiles, layout).sparseStitch() match {
873+
val raster: Raster[MultibandTile] = ContextSeq(tiles, layout).sparseStitch(geometry.extent) match {
873874
case Some(stitched) => stitched
874875
case _ => {
875876
logger.error("stitchAndWriteToTiff(): sparseStitch returned None. Recovering by writing an empty raster.")

0 commit comments

Comments
 (0)