VectorX Function Reference
VectorX provides a single conversion function for legacy DBLabs Mosaic geometry format.
SQL examples
Common setup
Run this once before the examples below. It registers VectorX so you can use st_legacyaswkb in Python and gbx_st_legacyaswkb in SQL.
from databricks.labs.gbx.vectorx.jts.legacy import functions as vx
vx.register(spark)
Example output
VectorX registered. You can now use st_legacyaswkb in Python and gbx_st_legacyaswkb in SQL.
st_legacyaswkb
Converts legacy Mosaic geometry to Well-Known Binary (WKB).
Parameters: legacyGeometry — Column containing legacy geometry string (e.g. {1, [[[x, y]]], [[]]}).
Returns: Binary WKB column.
Python:
from pyspark.sql import Row
from pyspark.sql.types import StructField, StructType
# Point (30, 10): typeId=1 (POINT), srid=0, boundaries=[[[30.0, 10.0]]], holes=[]
legacy_schema = _legacy_point_struct_schema()
schema = StructType([StructField("geom_legacy", legacy_schema)])
row = Row(geom_legacy=(1, 0, [[[30.0, 10.0]]], []))
shapes = spark.createDataFrame([row], schema)
shapes.select(vx.st_legacyaswkb("geom_legacy").alias("wkb")).show()
Example output
+-----------+
|wkb |
+-----------+
|[BINARY] |
+-----------+
SQL:
SELECT gbx_st_legacyaswkb(geom_legacy) AS wkb FROM legacy_table;
Example output
One row per input legacy geometry; wkb column contains binary WKB.
Next Steps
- Quick Start — Register and use VectorX with the legacy example
- API Overview — All GeoBrix APIs