jiayuasu commented on code in PR #2766:
URL: https://github.com/apache/sedona/pull/2766#discussion_r2958150490


##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -1151,6 +1151,71 @@ def line_merge(self, directed=False):
             returns_geom=True,
         )
 
+    def build_area(self, node=True):
+        if len(self) == 0:
+            return GeoSeries([], name="polygons", crs=self.crs)
+
+        if node:
+            aggr_expr = sta.ST_Union_Aggr(self.spark.column)
+        else:
+            aggr_expr = sta.ST_Collect_Agg(self.spark.column)
+
+        build_expr = stf.ST_BuildArea(aggr_expr)
+        dump_expr = F.explode(stf.ST_Dump(build_expr))
+
+        sdf = self._internal.spark_frame.select(dump_expr.alias("polygons"))
+
+        if not sdf.take(1):
+            return GeoSeries([], name="polygons", crs=self.crs)
+

Review Comment:
   `take(1)` is a lightweight Spark action (reads a single partition, no 
shuffle). We need it here because geopandas returns an empty `GeoSeries([], 
Name: polygons)` for non-closing linework, and removing the check would lose 
the `name="polygons"` metadata. Keeping it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to