| Crates.io | geoparquet-batch-writer-derive |
| lib.rs | geoparquet-batch-writer-derive |
| version | 0.1.4 |
| created_at | 2025-08-10 01:25:26.690426+00 |
| updated_at | 2025-08-21 01:01:04.472302+00 |
| description | A library for convenient batch writing of GeoParquet files (derive macro) |
| homepage | https://github.com/KotobaMedia/geoparquet-batch-writer/ |
| repository | https://github.com/KotobaMedia/geoparquet-batch-writer/ |
| max_upload_size | |
| id | 1788358 |
| size | 42,217 |
Rust library (plus derive macro) for writing GeoParquet files efficiently in batches using GeoArrow/Arrow. Define a simple row struct with a geometry field, derive GeoParquetRowData, and stream rows to an on-disk GeoParquet file.
max_rows_per_batchf64)Option<T> (including optional geometry)crates/core: library crate geoparquet-batch-writercrates/derive: proc-macro crate exporting #[derive(GeoParquetRowData)]crates/example-cli: example CLI demonstrating how to generate random data and write GeoParquet using the library (not published)# build the workspace (library + derive + example CLI)
cargo build -q
# run tests (core crate has unit tests)
cargo test -q
cargo add geoparquet-batch-writer
Add a row type and derive GeoParquetRowData. Mark exactly one geometry field with #[geo(geometry)]. Optionally rename columns or set geometry dimension.
use anyhow::Result;
use geo_types::Point;
use geoparquet_batch_writer::{BatchConfig, GeoParquetBatchWriter, GeoParquetRowData};
#[derive(GeoParquetRowData)]
struct Row {
id: u64,
#[geo(name = "geom", geometry, dim = "XY")] // XY | XYZ | XYM
point: Point<f64>,
note: Option<String>,
}
fn main() -> Result<()> {
let mut w: GeoParquetBatchWriter<Row> = GeoParquetBatchWriter::new(
"output.parquet",
Default::default(),
)?;
for i in 0..25_000u64 {
w.add_row(Row {
id: i,
point: Point::new(-120.0 + (i as f64 * 0.0001), 35.0),
note: (i % 2 == 0).then(|| format!("row {i}")),
})?;
}
w.finish()?; // flush remaining, write metadata, close file
Ok(())
}
Notes
Option<Point<f64>>) and will produce nullsAn example CLI lives in crates/example-cli to illustrate how to consume the library. It is for demonstration only and is not published to crates.io.
Run it like this:
# from repo root
cargo run -q -p geoparquet-batch-writer-example-cli -- \
--output output.parquet \
--count 10000 \
--bbox "-180,-90,180,90"
Flags
--output (path): where to write the GeoParquet file (default output.parquet)--count (usize): number of random points (default 10000)--bbox (min_lon,min_lat,max_lon,max_lat): bounding box for random points (default -180,-90,180,90)