ST_Aggr_StdevEllipse

ST_Aggr_StdevEllipse
Two aggregated groups of points (blue and orange) and the resulting standard deviational ellipses.

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.

FunctionSyntax
Pythonaggr_stdev_ellipse(geometry, num_stdev=1.0, weight=None, min_records=2)
SQLST_Aggr_StdevEllipse(geometry, num_stdev, weight, min_records)
ScalaaggrStdevEllipse(geometry, stdev, weight, minRecords)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for aggr_stdev_ellipse.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
Use dark colors for code blocksCopy
1
2
3
4
5
6
+---+--------------------+
| id|  aggr_stdev_ellipse|
+---+--------------------+
|  1|{"rings":[[[10.23...|
|  2|{"rings":[[[13.70...|
+---+--------------------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.