ST_GeomFromText takes a string column and returns a geometry column.
The string column must contain the well-known text (WKT)
representation of geometries. You can optionally specify a spatial reference for the result geometry column.
The sr
parameter value must be a valid SRID or WKT string.
This function should only be used when you don't know the geometry type represented by the input column or when the input column contains more than one geometry type. In other cases, use the function specific to the geometry type of your input data (i.e. ST_PointFromText, ST_LineFromText, ST_MPointFromText, or ST_PolyFromText).
Function | Syntax |
---|---|
Python | geom |
SQL | ST |
Scala | geom |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for geom_from_text.
This function implements the OpenGIS Simple Features Implementation Specification SQL 1.2.1.
Examples
from geoanalytics_fabric.sql import functions as ST
data = [
("POINT (-2533858.73 8107527.81)",),
("LINESTRING (-3636954.77 7750916.26, -3168756.90 7966747.98, -3124795.45 7893415.62)", )
]
df = spark.createDataFrame(data, ["wkt"])
df.select(ST.geom_from_text("wkt", sr=8857).alias("geom_from_text")).show(truncate=False)
+---------------------------------------------------------------------------------------+
|geom_from_text |
+---------------------------------------------------------------------------------------+
|{"x":-2533858.73,"y":8107527.81} |
|{"paths":[[[-3636954.77,7750916.26],[-3168756.9,7966747.98],[-3124795.45,7893415.62]]]}|
+---------------------------------------------------------------------------------------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |