ST_SRID

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.

FunctionSyntax
Pythonsrid(geometry, srid=None)
SQLST_SRID(geometry, srid)
Scalasrid(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

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
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()
Result-as-setter
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
+------------------+----+
|             point|srid|
+------------------+----+
|{"x":-178,"y":-17}|   0|
+------------------+----+

+------------------+----+
|             point|srid|
+------------------+----+
|{"x":-178,"y":-17}|4326|
+------------------+----+

Getter

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([("POINT (-2533858.73 8107527.81)",)], ["wkt"])\
          .select(ST.point_from_text("wkt", srid=54008).alias("geometry"))

df.select(ST.srid("geometry").alias("srid")).show()
Result-as-getter
Use dark colors for code blocksCopy
1
2
3
4
5
+-----+
| srid|
+-----+
|54008|
+-----+

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.