ST_PolyFromBinary

ST_PolyFromBinary takes a binary column and returns a polygon column. The input binary column must contain the well-known binary (WKB) 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.

FunctionSyntax
Pythonpoly_from_binary(wkb, sr=None)
SQLST_PolyFromBinary(wkb, sr)
ScalapolyFromBinary(wkb, sr)

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

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_binary= bytearray(b'\x01\x03\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00>@\x00\x00\x00\x00\x00\x006@\x00\x00\x00\x00\x00\x80A@\x00\x00\x00\x00\x00\x002@\x00\x00\x00\x00\x00\x00<@\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x00>@')

df = spark.createDataFrame([(polygon_binary,)], ["wkb"])

df.select(ST.poly_from_binary("wkb", sr=4326).alias("poly_from_binary")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+---------------------------------------------+
|poly_from_binary                             |
+---------------------------------------------+
|{"rings":[[[20,30],[18,28],[22,35],[20,30]]]}|
+---------------------------------------------+

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.