ST_PolyFromText

ST_PolyFromText takes a string column and returns a polygon column. The string column must contain the well-known text (WKT) representation of polygon geometries. You can optionally specify a spatial reference ID for the result polygon column. The sr parameter value must be a valid SRID or WKT string.

FunctionSyntax
Pythonpoly_from_text(wkt,sr=None)
SQLST_PolyFromText(wkt,sr)
ScalapolyFromText(wkt, sr)

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

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
from geoanalytics_fabric.sql import functions as ST

polygon_text = 'POLYGON ((-117.271 34.059, -117.225 33.919, -116.963 33.662, -116.668 33.712))'

df = spark.createDataFrame([(polygon_text,)], ["wkt"])

df.select(ST.poly_from_text("wkt", srid=4326).alias("poly_from_text")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-------------------------------------------------------------------------------------------------------+
|poly_from_text                                                                                         |
+-------------------------------------------------------------------------------------------------------+
|{"rings":[[[-117.271,34.059],[-116.668,33.712],[-116.963,33.662],[-117.225,33.919],[-117.271,34.059]]]}|
+-------------------------------------------------------------------------------------------------------+

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.