ST_NumGeometries takes a geometry column and returns an integer column. The output column represents the number of geometries in each record.
| Function | Syntax |
|---|---|
| Python | num |
| SQL | ST |
| Scala | num |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for num_geometries.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
from geoanalytics_fabric.sql import functions as ST
from pyspark.sql import functions as F
data = [
("POINT (10 30)",),
("LINESTRING (15 15, 10 15, 12 2)", ),
("MULTIPOINT (10 10, 20 20, 30 30)",),
("MULTILINESTRING ((0 0, 10 10), (10 10, 20 20))", )
]
df = spark.createDataFrame(data, ["wkt"]).select(ST.geom_from_text("wkt").alias("geometry"))
df.select(ST.num_geometries("geometry").alias("num_geometries")).show()Result
+--------------+
|num_geometries|
+--------------+
| 1|
| 1|
| 3|
| 2|
+--------------+Version table
| Release | Notes |
|---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |