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


##########
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)
+
+        internal = InternalFrame(
+            spark_frame=sdf,
+            index_spark_columns=None,
+            column_labels=[("polygons",)],
+            data_spark_columns=[scol_for(sdf, "polygons")],
+            data_fields=[InternalField(np.dtype("object"), 
sdf.schema["polygons"])],

Review Comment:
   The duplication is only between these two methods (`build_area` and 
`polygonize`). The other aggregate methods (`union_all` / `intersection_all`) 
return a single `BaseGeometry` via a different code path, so a shared helper 
would only serve two callers. Keeping them inline for now.



##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -26,7 +26,7 @@
 import pyspark
 from pyspark.pandas import Series as PandasOnSparkSeries
 from pyspark.pandas.frame import DataFrame as PandasOnSparkDataFrame
-from pyspark.pandas.internal import InternalFrame
+from pyspark.pandas.internal import InternalField, InternalFrame

Review Comment:
   Good catch. Moved `InternalField` to local imports inside `build_area` and 
`polygonize` — 96b298d.



-- 
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