ST_Segments

ST_Segments takes a linestring column and returns an array column. The function creates an array of linestrings by splitting the input linestring at a certain number of vertices using a moving window. By default the function will create segments with two points and the moving window will move one point at a time (step size of 1). You can optionally include a larger number of points in each linestring by specifying a numeric value greater than 2. You can also increase the step size by setting it to a value greater than 1. Setting the step size to one less than the number of points will always result in segments that touch but do not overlap.

FunctionSyntax
Pythonsegments(linestring, num_points=2, step_size=1)
SQLST_Segments(linestring, num_points, step_size)
Scalasegments(linestring, numPoints, stepSize)

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

Examples

PythonPythonSQLScala
1
2
3
4
5
6

from geoanalytics_fabric.sql import functions as ST, Linestring

df = spark.createDataFrame([(Linestring([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]]),)],["linestring"])

df.select(ST.segments("linestring", 3, 2).alias("segments")).show(truncate=False)
Result
1
2
3
4
5
+------------------------------------------------------------------+
|segments                                                          |
+------------------------------------------------------------------+
|[{"paths":[[[0,0],[1,0],[2,0]]]}, {"paths":[[[2,0],[3,0],[4,0]]]}]|
+------------------------------------------------------------------+

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.

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