ST_SRID can work as a getter or a setter, depending on the inputs.
Getter: ST_SRID takes a geometry column and returns the spatial reference ID (SRID) of the column as an integer column. If
the SRID of the input geometry column has not been set, the function returns 0
.
Setter: ST_SRID takes a geometry column and a numeric value and returns the input geometry column with its SRID set to the numeric value. This does not affect the geometry data in the column. To transform your geometry data from one spatial reference to another, use ST_Transform.
Function | Syntax |
---|---|
Python | srid(geometry, srid= |
SQL | ST |
Scala | srid(geometry, srid) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for srid.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Examples
Setter
from geoanalytics_fabric.sql import functions as ST, Point
df = spark.createDataFrame([(Point(-178, -17),)], ["point"])
df.withColumn("srid", ST.srid("point")).show()
df.select(ST.srid("point", 4326).alias("point"))\
.withColumn("srid", ST.srid("point")).show()
+------------------+----+
| point|srid|
+------------------+----+
|{"x":-178,"y":-17}| 0|
+------------------+----+
+------------------+----+
| point|srid|
+------------------+----+
|{"x":-178,"y":-17}|4326|
+------------------+----+
Getter
from geoanalytics_fabric.sql import functions as ST
df = spark.createDataFrame([("POINT (-2533858.73 8107527.81)",)], ["wkt"])\
.select(ST.point_from_text("wkt", srid=54008).alias("geometry"))
df.select(ST.srid("geometry").alias("srid")).show()
+-----+
| srid|
+-----+
|54008|
+-----+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |