ST_GeodesicDensify takes a geometry column and a numeric max value and returns a geometry column. This
function adds vertices along linestrings or polygons to create densified approximations of geodesic segments with each
segment being no longer than max.
The max can be specified with or without a unit. When specified without 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 in meters.
This function is more accurate but less performant than ST_Densify and requires that a spatial reference is set on the input geometry column. To learn more about the difference between planar and geodesic calculations, see Coordinate systems and transformations.
| Function | Syntax |
|---|---|
| Python | geodesic |
| SQL | ST |
| Scala | geodesic |
For more details, go to the GeoAnalytics Engine API reference for geodesic_densify.
Examples
from geoanalytics.sql import functions as ST
LINE_WKT = 'LINESTRING (117.61983168124925 34.061452833142205, 117.43262450694835 34.198818997647145)'
df = spark.createDataFrame([(LINE_WKT,)], ['wkt']) \
.withColumn("line", ST.line_from_text("wkt", 4326))
df.select(ST.geodesic_densify("line", 10000).alias("geodesic_densified")).show(truncate = False)+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|geodesic_densified |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|{"paths":[[[117.61983168124925,34.061452833142205],[117.55749656079557,34.10727359287857],[117.49509421655945,34.153062343775964],[117.43262450694834,34.198818997647145]]]}|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+Version table
| Release | Notes |
|---|---|
1.1.0 | Python and SQL functions introduced |
1.5.0 | Scala function introduced |
1.6.0 | max parameter accepts values with specified units |