oxigdal-flatgeobuf
A high-performance FlatGeobuf vector format driver for OxiGDAL - Pure Rust GDAL reimplementation. This crate provides streaming read/write support for FlatGeobuf files with R-tree spatial indexing and cloud-native HTTP range request capabilities.
Overview
FlatGeobuf is a performant binary encoding for geographic data that combines the efficiency of column-oriented storage with spatial indexing. This driver enables:
- Fast sequential reading of geographic features and properties
- Spatial indexing with packed R-tree for efficient range queries
- Cloud-native access with HTTP range requests (requires async feature)
- Full geometry support including Points, LineStrings, Polygons, and Multi* types
- Rich property types with automatic serialization/deserialization
- CRS metadata support for coordinate reference systems
Features
std(default): Standard library support with synchronous I/Oasync: Async I/O support with Tokio for non-blocking file operationshttp: Cloud-native access via HTTP range requests using ReqWest
Installation
Add to your Cargo.toml:
[]
= "0.1"
# With async support
= { = "0.1", = ["async"] }
# With HTTP support for cloud storage
= { = "0.1", = ["http"] }
Quick Start
Reading FlatGeobuf Files
use FlatGeobufReader;
use File;
Writing FlatGeobuf Files
use ;
use ;
use File;
Async I/O
use AsyncFlatGeobufReader;
async
HTTP Cloud-Native Access
use HttpReader;
async
API Overview
| Module | Description |
|---|---|
reader |
Synchronous and async FlatGeobuf reading with feature streaming |
writer |
FlatGeobuf writing with builder pattern for flexible configuration |
header |
Header metadata: geometry type, columns, CRS, extent information |
geometry |
Geometry encoding/decoding for all OGC geometry types |
index |
Packed R-tree spatial indexing for efficient range queries |
error |
Comprehensive error types with detailed context |
http |
Cloud-native HTTP reader with range request support (requires http feature) |
Geometry Support
The driver supports all standard OGC geometry types:
- Point: Single coordinate
- LineString: Connected sequence of coordinates
- Polygon: Closed linear rings with holes
- MultiPoint: Multiple disconnected points
- MultiLineString: Multiple disconnected linestrings
- MultiPolygon: Multiple disconnected polygons
- GeometryCollection: Heterogeneous geometry collection
Additionally, circular and curved geometry types are supported:
- CircularString, CompoundCurve, CurvePolygon, MultiCurve, MultiSurface, Curve, Surface, PolyhedralSurface, TIN, Triangle
Property Types
The driver supports the following property value types:
- Byte: Single byte values
- UByte: Unsigned byte values
- Short: 16-bit integers
- UShort: 16-bit unsigned integers
- Int: 32-bit integers
- UInt: 32-bit unsigned integers
- Long: 64-bit integers
- ULong: 64-bit unsigned integers
- Float: Single-precision floating point
- Double: Double-precision floating point
- String: UTF-8 encoded text
- Json: JSON-encoded structures
- DateTime: Date and time values
- Binary: Raw binary data
Spatial Indexing
FlatGeobuf supports packed R-tree spatial indexes for efficient spatial queries:
use FlatGeobufReader;
let mut reader = new?;
// Check if file has spatial index
if let Some = reader.index
CRS Support
FlatGeobuf can store coordinate reference system metadata:
let header = reader.header;
if let Some = &header.crs
Error Handling
This library follows the "no unwrap" policy. All fallible operations return Result<T, FlatGeobufError> with descriptive error context:
use ;
match new
Pure Rust
This library is 100% Pure Rust with no C/Fortran dependencies. All FlatGeobuf encoding, decoding, and spatial indexing is implemented in pure Rust, making it fully portable and safe.
Performance
Benchmarks demonstrate efficient feature streaming and spatial queries:
| Operation | Performance |
|---|---|
| Sequential read (1M features) | ~200ms |
| Spatial index query (R-tree) | O(log n) |
| Feature encoding | ~1μs per feature |
| Feature decoding | ~2μs per feature |
Examples
The crate includes runnable examples:
Inspect FlatGeobuf Files
Shows file structure, header metadata, R-tree index information, and sample features.
Create Test Samples
Generates sample FlatGeobuf files for testing and development.
See the examples directory for more usage patterns.
Documentation
Full API documentation is available at docs.rs/oxigdal-flatgeobuf.
OxiGDAL Ecosystem
This driver is part of the OxiGDAL ecosystem - a Pure Rust GDAL reimplementation:
- OxiGDAL Core: Vector and raster data model
- OxiGDAL Drivers: Format-specific readers/writers
- Raster Drivers: GeoTIFF, PNG, JPEG, HDF5
- Vector Drivers: Shapefile, GeoJSON, FlatGeobuf, GeoPackage
License
Licensed under the Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
Contributing
Contributions are welcome! Please open issues or pull requests on GitHub.
Part of the COOLJAPAN ecosystem - Pure Rust implementations of scientific computing libraries.