ST_PolyFromShape takes a binary column and returns a polygon column. The input binary column must contain the
shapefile representation of polygon geometries. You can optionally specify a
spatial reference for the result polygon column. The sr parameter value must be a valid SRID or WKT string.
If a polygon cannot be created from the input binary the function will return null.
| Function | Syntax |
|---|---|
| Python | poly |
| SQL | ST |
| Scala | poly |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for poly_from_shape.
Examples
from geoanalytics_fabric.sql import functions as ST
poly_shape = bytearray(b'\x05\x00\x00\x00\x00\x00\x00\x00\x00\x002@\x00\x00\x00\x00\x00\x00<@\x00\x00\x00\x00\x00\x006@\x00\x00\x00\x00\x00\x80A@\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00>@\x00\x00\x00\x00\x00\x002@\x00\x00\x00\x00\x00\x00<@\x00\x00\x00\x00\x00\x006@\x00\x00\x00\x00\x00\x80A@\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00>@')
df = spark.createDataFrame([(poly_shape, )], ["shape"])
df.select(ST.poly_from_shape("shape", sr=4326).alias("poly_from_shape")).show(truncate=False)Result
+---------------------------------------------+
|poly_from_shape |
+---------------------------------------------+
|{"rings":[[[20,30],[18,28],[22,35],[20,30]]]}|
+---------------------------------------------+Version table
| Release | Notes |
|---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |