ST_SRText

ST_SRText can work as a getter or a setter, depending on the inputs.

Getter: ST_SRText takes a geometry column and returns the spatial reference of the column as a string in Well-Known Text (WKT) format. If the spatial reference of the input geometry column has not been set, the function returns an empty string.

Setter: ST_SRText takes a geometry column and a spatial reference string in Well-Known Text (WKT) format and returns the input geometry column with its spatial reference set to the string 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
Pythonsr_text(geometry, wkt=None)
SQLST_SRtext(geometry, wkt)
ScalasrText(geometry, wkt)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for sr_text.

Examples

Setter

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from geoanalytics_fabric.sql import functions as ST, Point

wkt_4326 = ('GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",'
            'SPHEROID["WGS_1984",6378137.0,298.257223563]],'
            'PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]')

df = spark.createDataFrame([(Point(-178, -17),)], ["point"])

df.withColumn("sr_text", ST.sr_text("point")).show()

df.select(ST.sr_text("point", wkt_4326).alias("point"))\
  .withColumn("sr_text", ST.sr_text("point")).show(truncate=False)
Result-as-setter
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
+------------------+-------+
|             point|sr_text|
+------------------+-------+
|{"x":-178,"y":-17}|       |
+------------------+-------+

+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|point             |sr_text                                                                                                                                          |
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
|{"x":-178,"y":-17}|GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]|
+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+

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", sr=54008).alias("geometry"))

df.select(ST.sr_text("geometry").alias("sr_text")).show(truncate=False)
Result-as-getter
Use dark colors for code blocksCopy
1
2
3
4
5
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|sr_text                                                                                                                                                                                                                                                                                                                 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|PROJCS["World_Sinusoidal",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Sinusoidal"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],UNIT["Meter",1.0]]|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

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.