ST_Densify

ST_Densify takes a geometry column and a numeric max_segment_length value and returns a geometry column. This function adds vertices along linestrings or polygons such that every segment within the geometry is no longer than max_segment_length, using planar distance calculation. The max_segment_length parameter is in the same units as the input geometry and should be greater than zero. For example, if your input geometry is in a spatial reference that uses meters, you should specify the max_segment_length in meters.

To densify geometry using geodesic distance calculation, use ST_GeodesicDensify.

FunctionSyntax
Pythondensify(geometry, max_segment_length)
SQLST_Densify(geometry, max_segment_length)
Scaladensify(geometry, maxSegmentLength)

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

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
from geoanalytics_fabric.sql import functions as ST

df = spark.createDataFrame([("LINESTRING (0 0, 10 0)",)], ['wkt']) \
        .withColumn("line", ST.line_from_text("wkt"))

df.select(ST.densify("line", 2.5).alias("densified")).show(truncate = False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+------------------------------------------------+
|densified                                       |
+------------------------------------------------+
|{"paths":[[[0,0],[2.5,0],[5,0],[7.5,0],[10,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.