Write to Geoparquet using native Geoarrow encoding #681
-
I may have got it wrong or there may not be an implementation yet but - is it possible to write Geoparquet using native Geoarrow encoding? I have noticed in the source code that it uses WKB: pub fn write_geoparquet<W: Write + Send>(
table: &mut GeoTable,
writer: W,
writer_properties: Option<WriterProperties>,
) -> Result<()> {
// Create geo metadata before casting to WKB so that we can compute geometry types and bbox
// more efficiently.
let geo_meta = create_metadata(table)?;
// Cast geometry column to WKB and update geometry column in table.
let wkb_geometry = table.geometry()?.as_ref().to_wkb::<i32>();
table.remove_column(table.geometry_column_index());
let field = wkb_geometry.extension_field();
table.append_column(
field,
ChunkedArray::new(
wkb_geometry
.chunks
.into_iter()
.map(|chunk| chunk.into_array_ref())
.collect(),
),
)?;
let schema = table.schema();
let mut writer = ArrowWriter::try_new(writer, schema.clone(), writer_properties)?;
writer.append_key_value_metadata(geo_meta);
for batch in table.batches() {
writer.write(batch)?;
}
writer.close()?;
Ok(())
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
👋 Sorry I've been on vacation much of the last week. No, there's not yet an implementation of writing GeoParquet 1.1 with native encoding. You can get pretty close by casting to the separated coordinate layout and then using the |
Beta Was this translation helpful? Give feedback.
👋 Sorry I've been on vacation much of the last week.
No, there's not yet an implementation of writing GeoParquet 1.1 with native encoding. You can get pretty close by casting to the separated coordinate layout and then using the
parquet
crate directly (it'll just be missing GeoParquet metadata unless you construct and add that yourself). I've been planning to implement the writing side of GeoParquet 1.1 after updating the reader side in #660