ST_NumGeometries

ST_NumGeometries takes a geometry column and returns an integer column. The output column represents the number of geometries in each record.

FunctionSyntax
Pythonnum_geometries(geometry)
SQLST_NumGeometries(geometry)
ScalanumGeometries(geometry)

For more details, go to the GeoAnalytics Engine API reference for num_geometries.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
1
2
3
4
5
6
7
8
9
10
11
12
13
14

from geoanalytics.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
1
2
3
4
5
6
7
8
+--------------+
|num_geometries|
+--------------+
|             1|
|             1|
|             3|
|             2|
+--------------+

Version table

ReleaseNotes

1.0.0

Python and SQL functions introduced

1.5.0

Scala function introduced

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

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close