Skip to content

Commit

Permalink
pixel wise masking was not applying the mask for tiles where all pixe…
Browse files Browse the repository at this point in the history
…ls were masked
  • Loading branch information
jdries committed Jun 10, 2024
1 parent e378dab commit 05f0fab
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ object DatacubeSupport {
spacetimeMask.reproject(metadata.crs,metadata.layout,16,rdd.partitioner)._2
}

// retain only tiles where there is at least one valid pixel (mask value == 0), others will be fully removed
val filtered = alignedMask.withContext{_.filter(_._2.band(0).toArray().exists(pixel => pixel == 0))}

if (pixelwiseMasking) {
val spacetimeDataContextRDD = ContextRDD(rdd, metadata)
// maskingCube is only set from Python when replacement is not defined
rasterMaskGeneric(spacetimeDataContextRDD, alignedMask, null, ignoreKeysWithoutMask = true)
rasterMaskGeneric(spacetimeDataContextRDD, filtered, null, ignoreKeysWithoutMask = true)
} else {

// retain only tiles where there is at least one valid pixel (mask value == 0)
val filtered = alignedMask.withContext{_.filter(_._2.band(0).toArray().exists(pixel => pixel == 0))}
rdd.join(filtered).mapValues(_._1)
}
} else {
Expand Down

0 comments on commit 05f0fab

Please sign in to comment.