Expand description
Read and write the GeoParquet format.
§Examples of reading GeoParquet file into a GeoTable
§Synchronous reader
use std::fs::File;
use arrow_array::RecordBatch;
use arrow_array::RecordBatchReader;
use arrow_schema::ArrowError;
use geoparquet::{GeoParquetReaderOptions, GeoParquetRecordBatchReaderBuilder};
let file = File::open("../../fixtures/geoparquet/nybb.parquet").unwrap();
let geo_options = GeoParquetReaderOptions::default().with_batch_size(65536);
// let reader_builder =
let reader = GeoParquetRecordBatchReaderBuilder::try_new_with_options(
file,
Default::default(),
geo_options,
)
.unwrap()
.build()
.unwrap();
// The schema of the stream of record batches
let schema = reader.schema();
let batches = reader
.collect::<Result<Vec<RecordBatch>, ArrowError>>()
.unwrap();
println!("Schema: {}", schema);
println!("Num batches: {}", batches.len());
§Asynchronous reader
use geoparquet::{GeoParquetReaderOptions, GeoParquetRecordBatchStreamBuilder};
use tokio::fs::File;
#[tokio::main]
async fn main() {
let file = File::open("../../fixtures/geoparquet/nybb.parquet")
.await
.unwrap();
let geo_options = GeoParquetReaderOptions::default().with_batch_size(65536);
let reader = GeoParquetRecordBatchStreamBuilder::try_new_with_options(
file,
Default::default(),
geo_options,
)
.await
.unwrap()
.build()
.unwrap();
let (batches, schema) = reader.read_table().await.unwrap();
println!("Schema: {}", schema);
println!("Num batches: {}", batches.len());
}
Modules§
- metadata
- Strongly-typed structs corresponding to the metadata provided by the GeoParquet specification.
Structs§
- GeoParquet
Dataset Metadata - The metadata necessary to represent a collection of (Geo)Parquet files that share the same schema.
- GeoParquet
Reader Metadata - The metadata necessary to construct a
GeoParquetRecordBatchReaderBuilder
or [GeoParquetRecordBatchStreamBuilder
]. - GeoParquet
Reader Options - Options for reading (Geo)Parquet
- GeoParquet
Record Batch Reader - An
Iterator<Item = ArrowResult<RecordBatch>>
that yieldsRecordBatch
read from a Parquet data source. This will parse any geometries to their native representation. - GeoParquet
Record Batch Reader Builder - A synchronous builder used to construct
GeoParquetRecordBatchReader
for a file. - GeoParquet
Writer - A synchronous GeoParquet file writer
- GeoParquet
Writer Options - Options for writing GeoParquet
Enums§
- GeoParquet
Writer Encoding - Allowed encodings when writing to GeoParquet
Functions§
- write_
geoparquet - Write a RecordBatchReader to GeoParquet.