ST_Aggr_StdevEllipse operates on a grouped DataFrame and returns the weighted aggregate standard deviational ellipse of geometries in each group. You can optionally specify one or more of the following:
- A double value for the size of the returned ellipse in standard deviations. The default is one standard deviation.
- A numeric column which weights the locations according to their relative importance. The default is unweighted.
- An integer value for the minimum number of records that must be in a group for a standard deviation to be calculated. The default is 2.
You can group your DataFrame using DataFrame.groupBy() or with a GROUP BY clause in a SQL statement.
To learn more, see How Directional Distribution (Standard Deviational Ellipse) works.
Function | Syntax |
---|---|
Python | aggr |
SQL | ST |
Scala | aggr |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for aggr_stdev_ellipse.
Examples
from geoanalytics_fabric.sql import functions as ST, Polygon
data = [
(1, 0.3, Polygon([[[5,5],[12,5],[12,10],[5,10],[5,5]]])),
(1, 1.1, Polygon([[[10,8],[14,8],[14,15],[10,15],[10,8]]])),
(2, 3.6, Polygon([[[6,8],[20,8],[20,20],[6,20],[6,8]]])),
(2, 0.7, Polygon([[[10,5],[20,10],[20,20],[10,20],[10,5]]]))
]
df = spark.createDataFrame(data, ["id", "weight", "polygon"])
df.groupBy("id")\
.agg(ST.aggr_stdev_ellipse("polygon", num_stdev=0.5, weight="weight").alias("aggr_stdev_ellipse"))\
.show()
Result
+---+--------------------+
| id| aggr_stdev_ellipse|
+---+--------------------+
| 1|{"rings":[[[10.23...|
| 2|{"rings":[[[13.70...|
+---+--------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |