Skip to main content

VectorX

Full API reference

For the complete list of VectorX functions with parameters and examples, see the VectorX Function Reference.

VectorX converts legacy DBLabs Mosaic geometry strings to Well-Known Binary (WKB) for use with Databricks spatial functions.

Import path

Use databricks.labs.gbx.vectorx.jts.legacy (Python) or com.databricks.labs.gbx.vectorx.jts.legacy (Scala).

Example

Convert a legacy point to WKB (same example as Quick Start):

# Register VectorX, create legacy point struct, convert to WKB
from databricks.labs.gbx.vectorx.jts.legacy import functions as vx
from pyspark.sql import Row
from pyspark.sql.types import ArrayType, DoubleType, IntegerType, StructField, StructType
vx.register(spark)
legacy_schema = StructType([
StructField("typeId", IntegerType()),
StructField("srid", IntegerType()),
StructField("boundaries", ArrayType(ArrayType(ArrayType(DoubleType())))),
StructField("holes", ArrayType(ArrayType(ArrayType(ArrayType(DoubleType()))))),
])
row = Row(geom_legacy=(1, 0, [[[30.0, 10.0]]], []))
shapes = spark.createDataFrame([row], StructType([StructField("geom_legacy", legacy_schema)]))
shapes.select(vx.st_legacyaswkb("geom_legacy").alias("wkb")).show()
Example output
+-----------+
|wkb |
+-----------+
|[BINARY] |
+-----------+

Learn more