ST_Densify takes a geometry column and a numeric max 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, using planar distance calculation.
The max can be specified with or without a unit. When specified with a unit, the max
can be defined using ST_CreateDistance or with a tuple containing a number and
a unit string (e.g., (10, "kilometers")). When specified without a unit, the max can be a single value
or a numeric column that is greater than zero, and it is assumed to be in the same units as the input geometry. For example,
if your input geometry is in a spatial reference that uses meters, and max is specified without a unit,
the max value is in meters.
To densify geometry using geodesic distance calculation, use ST_GeodesicDensify.
| Function | Syntax | 
|---|---|
| Python | densify(geometry, max | 
| SQL | ST | 
| Scala | densify(geometry, max | 
For more details, go to the GeoAnalytics Engine API reference for densify.
Examples
from geoanalytics.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)+------------------------------------------------+
|densified                                       |
+------------------------------------------------+
|{"paths":[[[0,0],[2.5,0],[5,0],[7.5,0],[10,0]]]}|
+------------------------------------------------+Version table
| Release | Notes | 
|---|---|
| 1.1.0 | Python and SQL functions introduced | 
| 1.5.0 | Scala function introduced | 
| 1.6.0 | maxparameter accepts values specified with units |