diff --git a/python/test/test_raster_functions.py b/python/test/test_raster_functions.py index 565ec2913..be5fd4656 100644 --- a/python/test/test_raster_functions.py +++ b/python/test/test_raster_functions.py @@ -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() @@ -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 = ( diff --git a/src/main/scala/com/databricks/labs/mosaic/core/raster/gdal/MosaicRasterBandGDAL.scala b/src/main/scala/com/databricks/labs/mosaic/core/raster/gdal/MosaicRasterBandGDAL.scala index c7a2d9f6a..5ff3ceeaf 100644 --- a/src/main/scala/com/databricks/labs/mosaic/core/raster/gdal/MosaicRasterBandGDAL.scala +++ b/src/main/scala/com/databricks/labs/mosaic/core/raster/gdal/MosaicRasterBandGDAL.scala @@ -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 } } diff --git a/src/test/scala/com/databricks/labs/mosaic/expressions/raster/RST_TessellateBehaviors.scala b/src/test/scala/com/databricks/labs/mosaic/expressions/raster/RST_TessellateBehaviors.scala index c14db38a3..8804968e1 100644 --- a/src/test/scala/com/databricks/labs/mosaic/expressions/raster/RST_TessellateBehaviors.scala +++ b/src/test/scala/com/databricks/labs/mosaic/expressions/raster/RST_TessellateBehaviors.scala @@ -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") @@ -55,7 +55,7 @@ trait RST_TessellateBehaviors extends QueryTest { val netcdfResult = netcdfGridTiles.collect() - netcdfResult.length should be(842) + netcdfResult.length should be(491) }