Crate geoparquet

Source
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§

GeoParquetDatasetMetadata
The metadata necessary to represent a collection of (Geo)Parquet files that share the same schema.
GeoParquetReaderMetadata
The metadata necessary to construct a GeoParquetRecordBatchReaderBuilder or [GeoParquetRecordBatchStreamBuilder].
GeoParquetReaderOptions
Options for reading (Geo)Parquet
GeoParquetRecordBatchReader
An Iterator<Item = ArrowResult<RecordBatch>> that yields RecordBatch read from a Parquet data source. This will parse any geometries to their native representation.
GeoParquetRecordBatchReaderBuilder
A synchronous builder used to construct GeoParquetRecordBatchReader for a file.
GeoParquetWriter
A synchronous GeoParquet file writer
GeoParquetWriterOptions
Options for writing GeoParquet

Enums§

GeoParquetWriterEncoding
Allowed encodings when writing to GeoParquet

Functions§

write_geoparquet
Write a RecordBatchReader to GeoParquet.