Skip to content

Commit

Permalink
apply_dimension(dim=bands) => do not filter out all nodata tiles, but…
Browse files Browse the repository at this point in the history
… replace them with 'empty' tile. This avoids issues in subsequent merge_cubes with spatial cube or linear interpolation over time.

WorldCereal/worldcereal-classification#141
  • Loading branch information
jdries committed Sep 19, 2024
1 parent a201d12 commit a5a8328
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,15 @@ class OpenEOProcesses extends Serializable {
return ContextRDD(new org.apache.spark.rdd.PairRDDFunctions[K,MultibandTile](datacube).mapValues(tile => {
if (!tile.isInstanceOf[EmptyMultibandTile]) {
val resultTiles = function(tile.bands)
MultibandTile(resultTiles)
if(resultTiles.exists(!_.isNoDataTile)){
MultibandTile(resultTiles)
}else{
new EmptyMultibandTile(tile.cols,tile.rows,tile.cellType,tile.bandCount)
}
}else{
tile
}
}).filter(_._2.bands.exists(!_.isNoDataTile)),datacube.metadata.copy(cellType = scriptBuilder.getOutputCellType()))
}),datacube.metadata.copy(cellType = scriptBuilder.getOutputCellType()))
}

def filterEmptyTile[K:ClassTag](datacube:MultibandTileLayerRDD[K]): RDD[(K, MultibandTile)] with Metadata[TileLayerMetadata[K]]={
Expand Down

0 comments on commit a5a8328

Please sign in to comment.