Box2DType
box2d columns, such as the result of ST_Box2D.
Values are sedona.spark.core.geom.box2d.Box2D objects in Python, with
xmin, ymin, xmax and ymax attributes. A column of this type is
stored as a struct of those four doubles.
Box3DType
box3d columns, such as the result of ST_Box3D.
Values are sedona.spark.core.geom.box3d.Box3D objects in Python, with
xmin, ymin, zmin, xmax, ymax and zmax attributes. A
column of this type is stored as a struct of those six doubles.
geography_type
geometry_type
is_geography_type
data_type is a geography column type in either mode: Sedona’s
GeographyType UDT, or (PySpark >= 4.1) Spark’s native GeographyType.
Parameters
Returns
is_geometry_type
data_type is a geometry column type in either mode: Sedona’s
GeometryType UDT, or (PySpark >= 4.1) Spark’s native GeometryType.
Parameters
Returns
LegacyGeographyType
Geography values
requires an explicit legacy schema and verifySchema=False because those
values no longer carry a UDT marker. Use to_spark_geography for native input.
LegacyGeometryType
verifySchema=False. For ordinary native input, use to_spark_geometry.
RasterType
sedona.spark.raster.SedonaRaster objects in
Python, which DataFrame.collect() and Python UDFs receive. Converting
raster values requires rasterio; without it, they raise
NotImplementedError. Only in-db rasters can be converted back to a
raster column, for example when a UDF returns one.
to_shapely
DataFrame.collect() to shapely.
UDT-typed columns already deserialize to shapely and are returned as-is. Native
columns (PySpark >= 4.1) yield pyspark.sql.types.Geometry (WKB + SRID), which
is parsed here; the SRID is attached via shapely.set_srid when available
(shapely >= 2.0). None passes through. Spark’s native types validate their supported SRIDs.
The native wrapper is detected structurally (getBytes/getSrid), which
covers both pyspark.sql.types.Geometry and pyspark.sql.types.Geography —
native geography values also parse to (planar) shapely geometries. Sedona’s own
UDT geography columns deserialize to sedona.spark.core.geom.geography.Geography
pass through unchanged on older runtimes and unwrap on Spark 4.2+. Field order is normalized defensively: PySpark 4.1’s own internal conversion is
asymmetric (toInternal writes the key wkb while fromInternal reads
bytes), so depending on the collect path the wrapper can arrive with swapped
fields, or the raw {"srid": ..., "wkb"/"bytes": ...} dict can surface directly.
Parameters
Returns
The value as a Shapely geometry. Shapely geometries and None are returned
unchanged. Sedona
Geography objects are unwrapped on Spark 4.2 and
later, and returned unchanged on older runtimes.to_spark_geography
None is preserved.
Parameters
A Shapely geometry, Sedona Geography wrapper, existing Spark native
geography value, or None. A Sedona wrapper’s nonzero SRID takes precedence
over the SRID stored in its Shapely geometry.
Returns
A native geography on Spark 4.2 or later, a Sedona Geography wrapper on
older runtimes, or None for a null input.
to_spark_geometry
pyspark.sql.types.Geometry. Older Spark
versions accept Shapely directly through Sedona’s UDT and return it unchanged.
None is preserved. Native conversion requires Shapely 2 or later.
Parameters
A Shapely geometry, an existing native geometry value, or None.

