ST_Transform takes a geometry column and a spatial reference value and returns a geometry column. The function returns
the input geometries transformed into the specified spatial reference. It will also set the spatial reference of the result column.
The input geometry column must have a spatial reference set. The spatial reference value must be either
a numeric spatial reference (SRID) or a string value in Well-Known Text (WKT) format. Because the most appropriate
transformation path may vary based on the extent of the dataset, the original
Coordinate System of the data, or the type of analysis you
want to conduct, ST_Transform also optionally takes in a list of 4 numeric values representing the extent to consider
when determining the best transformation to use. ST_Transform also optionally takes a string value of the transformation
path to use when transforming between geographic spatial references. When datum
is not specified,
ST_Transform will automatically look up the best transformation path to use given the spatial reference of the input
geometry column and the spatial reference (specified with sr
) to transform into. The datum
parameter
overrides the session-level transform settings as well as the extent
parameter. Both extent
and datum
are available in Python only and are not supported in SQL.
To learn more about what it means to transform your geometry data, see Coordinate systems and transformations.
To set the spatial reference of a geometry column using spatial reference ID format without transforming the geometries, use ST_SRID.
To set the spatial reference of a geometry column using spatial reference WKT format without transforming the geometries, use ST_SRText.
Function | Syntax |
---|---|
Python | transform(geometry, sr, *, extent= |
SQL | ST |
Scala | transform(geometry, sr) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for transform.
Examples
from geoanalytics_fabric.sql import functions as ST
df = spark.createDataFrame([("POINT (10 30)",)],["wkt"])\
.withColumn("point", ST.point_from_text("wkt", 4326))
df.select(ST.transform("point", 3857, extent=[-30,-50,30,50]).alias("transform"))\
.withColumn("srid", ST.srid("transform")).show(truncate=False)
+-----------------------------------------------+----+
|transform |srid|
+-----------------------------------------------+----+
|{"x":1113194.9079327357,"y":3503549.8435043744}|3857|
+-----------------------------------------------+----+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |