Function
ST_Distance¶
Introduction: Return the Euclidean distance between A and B
Format: ST_Distance (A:geometry, B:geometry)
Since: v1.2.0
Spark SQL example:
SELECT ST_Distance(polygondf.countyshape, polygondf.countyshape)
FROM polygondf
ST_Transform¶
Introduction:
Transform the Spatial Reference System / Coordinate Reference System of A, from SourceCRS to TargetCRS
Note
By default, this function uses lat/lon order. You can use ST_FlipCoordinates to swap X and Y.
Note
If ST_Transform throws an Exception called "Bursa wolf parameters required", you need to disable the error notification in ST_Transform. You can append a boolean value at the end.
Format: ST_Transform (A:geometry, SourceCRS:string, TargetCRS:string ,[Optional] DisableError)
Since: v1.2.0
Spark SQL example (simple):
SELECT ST_Transform(polygondf.countyshape, 'epsg:4326','epsg:3857')
FROM polygondf
Spark SQL example (with optional parameters):
SELECT ST_Transform(polygondf.countyshape, 'epsg:4326','epsg:3857', false)
FROM polygondf
Note
The detailed EPSG information can be searched on EPSG.io.
ST_Buffer¶
Introduction: Returns a geometry/geography that represents all points whose distance from this Geometry/geography is less than or equal to distance.
Format: ST_Buffer (A:geometry, buffer: Double)
Since: v1.2.0
Spark SQL example:
SELECT ST_Buffer(polygondf.countyshape, 1)
FROM polygondf
ST_FlipCoordinates¶
Introduction: Returns a version of the given geometry with X and Y axis flipped.
Format: ST_FlipCoordinates(A:geometry)
Since: v1.2.0
Spark SQL example:
SELECT ST_FlipCoordinates(df.geometry)
FROM df
Input: POINT (1 2)
Output: POINT (2 1)
ST_GeoHash¶
Introduction: Returns GeoHash of the geometry with given precision
Format: ST_GeoHash(geom: geometry, precision: int)
Since: v1.2.0
Example:
Query:
SELECT ST_GeoHash(ST_GeomFromText('POINT(21.427834 52.042576573)'), 5) AS geohash
Result:
+-----------------------------+
|geohash |
+-----------------------------+
|u3r0p |
+-----------------------------+