Skip to content

Commit

Permalink
updated logic for checking empty band to exclude masked areas
Browse files Browse the repository at this point in the history
  • Loading branch information
sllynn committed Feb 13, 2024
1 parent 9043e03 commit 6a79482
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/test/test_raster_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_raster_flatmap_functions(self):
)

tessellate_result.write.format("noop").mode("overwrite").save()
self.assertEqual(tessellate_result.count(), 140)
self.assertEqual(tessellate_result.count(), 66)

overlap_result = (
self.generate_singleband_raster_df()
Expand All @@ -127,7 +127,7 @@ def test_raster_flatmap_functions(self):
)

overlap_result.write.format("noop").mode("overwrite").save()
self.assertEqual(overlap_result.count(), 196)
self.assertEqual(overlap_result.count(), 87)

def test_raster_aggregator_functions(self):
collection = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ case class MosaicRasterBandGDAL(band: Band, id: Int) {
* Returns true if the band is empty.
*/
def isEmpty: Boolean = {
val minMaxVals = Array.fill[Double](2)(0)
band.ComputeRasterMinMax(minMaxVals, 0)
minMaxVals.head == minMaxVals.last && minMaxVals.head == noDataValue
val stats = band.AsMDArray().GetStatistics()
stats.getValid_count == 0
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait RST_TessellateBehaviors extends QueryTest {

val result = gridTiles.collect()

result.length should be(980)
result.length should be(462)

val netcdf = spark.read
.format("gdal")
Expand All @@ -55,7 +55,7 @@ trait RST_TessellateBehaviors extends QueryTest {

val netcdfResult = netcdfGridTiles.collect()

netcdfResult.length should be(842)
netcdfResult.length should be(491)

}

Expand Down

0 comments on commit 6a79482

Please sign in to comment.