ST_PointN

ST_PointN takes a geometry column and an integer and returns a point column. The output column represents the nth point in the input geometry, where 0 is the first point. If the nth point does not exist the function returns null. This function always returns null for multipart linestrings and multipart polygons.

FunctionSyntax
Pythonpoint_n(geometry, n)
SQLST_PointN(geometry, n)
ScalapointN(geometry, n)

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

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
15

from geoanalytics.sql import functions as ST

data = [
    ("POINT (10 30)",),
    ("MULTIPOINT (0 0, 5 5, 0 5)", ),
    ("LINESTRING (15 15, 10 15, 12 2)", ),
    ("POLYGON ((20 30, 18 28, 22 35, 40 20))", ),
    ("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.point_n("geometry", 2).alias("point_n")).show()
Result
1
2
3
4
5
6
7
8
9
+---------------+
|        point_n|
+---------------+
|           NULL|
|  {"x":0,"y":5}|
| {"x":12,"y":2}|
|{"x":22,"y":35}|
|           NULL|
+---------------+

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