Skip to content

Commit

Permalink
added final tests for raster aggregators
Browse files Browse the repository at this point in the history
  • Loading branch information
sllynn committed Nov 9, 2023
1 parent 943ff63 commit f5525c5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions python/test/test_raster_functions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import random
import unittest

Expand Down Expand Up @@ -124,3 +125,33 @@ def test_raster_flatmap_functions(self):

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

def test_raster_aggregator_functions(self):
collection = (
self.generate_singleband_raster_df()
.withColumn("extent", api.st_astext(api.rst_boundingbox("tile")))
.withColumn(
"rst_to_overlapping_tiles",
api.rst_to_overlapping_tiles("tile", lit(200), lit(200), lit(10)),
)
)

merge_result = (
collection.groupBy("path")
.agg(api.rst_merge_agg("tile").alias("tile"))
.withColumn("extent", api.st_astext(api.rst_boundingbox("tile")))
)

self.assertEqual(merge_result.count(), 1)
self.assertEqual(collection.first()["extent"], merge_result.first()["extent"])

combine_avg_result = (
collection.groupBy("path")
.agg(api.rst_combineavg_agg("tile").alias("tile"))
.withColumn("extent", api.st_astext(api.rst_boundingbox("tile")))
)

self.assertEqual(combine_avg_result.count(), 1)
self.assertEqual(
collection.first()["extent"], combine_avg_result.first()["extent"]
)

0 comments on commit f5525c5

Please sign in to comment.