Apache Sedona expects geometries in GeoParquet files to be stored in the standard WKB (Well-Known Binary) format. When geometries are stored as JTS geometry objects directly (e.g., serialized Java objects), Sedona cannot read them because it does not support that serialization format natively.
Why the problem occurs:
- Sedona's GeoParquet reader expects geometry columns to be in a binary format (WKB).
- JTS geometry objects serialized directly are Java-specific and not interoperable with Sedona's reader.
- There is no built-in support in Sedona to deserialize JTS geometry objects from GeoParquet.
Workarounds that avoid conversion to WKB and back?
Unfortunately, no direct workaround exists that completely avoids converting JTS geometry objects to a binary format like WKB or WKT for Sedona to read them. This is because:
- GeoParquet is designed to store geometries in a standardized format (WKB or WKT).
- Sedona relies on this standard to parse geometries efficiently.
- JTS geometry objects are Java-specific and not part of the GeoParquet spec.
Recommended approaches:
-
Convert JTS geometry to WKB before writing GeoParquet:
- This is the standard approach.
- Use
Geometry.toBinary() or WKBWriter to convert JTS geometry to WKB.
- Store the WKB bytes in the GeoParquet geometry column.
- Sedona can then read the WKB directly without extra conversion.
-
If you control the writing process, write geometries as WKT:
- Sedona can also read WKT strings.
- This avoids binary conversion but still requires serialization to a standard text format.
-
Custom reader (not recommended):
- Implement a custom reader that deserializes JTS geometry objects from the GeoParquet file.
- This is complex and breaks interoperability.
Summary
- No native support in Sedona for JTS geometry objects in GeoParquet.
- Conversion to WKB or WKT is necessary for interoperability.
- This conversion is typically done once at write time, so it is not a heavy runtime cost.
If you want, I can help you with code snippets to convert JTS geometry to WKB before writing GeoParquet, or how to read WKB geometry in Sedona. Would you like that?