14 unstable releases (4 breaking)

new 0.4.0-beta.2 Dec 11, 2024
0.4.0-beta.1 Oct 4, 2024
0.3.0 Sep 7, 2024
0.3.0-beta.2 Aug 23, 2024
0.0.0 Sep 29, 2022

#39 in Geospatial

Download history 180/week @ 2024-08-21 2/week @ 2024-08-28 950/week @ 2024-09-04 447/week @ 2024-09-11 637/week @ 2024-09-18 282/week @ 2024-09-25 264/week @ 2024-10-02 238/week @ 2024-10-09 813/week @ 2024-10-16 329/week @ 2024-10-23 356/week @ 2024-10-30 275/week @ 2024-11-06 191/week @ 2024-11-13 443/week @ 2024-11-20 236/week @ 2024-11-27 394/week @ 2024-12-04

1,309 downloads per month
Used in 7 crates (6 directly)

MIT/Apache

4.5MB
39K SLoC

A Rust implementation of the GeoArrow specification, including algorithms implemented on and returning these GeoArrow arrays.

Reading and writing

The [io] module has functions for reading and writing GeoArrow data from a variety of formats. To use most format readers and writers, you must enable their corresponding feature. For example, to convert between geojson and GeoArrow, enable the geozero feature in your Cargo.toml:

[dependencies]
geoarrow = { version = "*" }

Then:

use std::{io::Cursor, fs::File};

// Reads geojson from a file into a GeoArrow table.
let file = File::open("fixtures/roads.geojson").unwrap();
let table = geoarrow::io::geojson::read_geojson(file, None).unwrap();

// Writes that table to a cursor as JSON, then reads it back into a `serde_json::Value`.
let mut cursor = Cursor::new(Vec::new());
geoarrow::io::geojson::write_geojson(table, &mut cursor);
let value: serde_json::Value = serde_json::from_slice(&cursor.into_inner()).unwrap();

See the [io] module for more information on the available formats and their features.

Constructing

You can build GeoArrow arrays all at once from [mod@geo] structures, or anything that implements geometry traits, e.g. PointTrait. Along with the GeoRust community, geoarrow-rs has been prototyping geometry access traits for a standardized way to access coordinate information, regardless of the storage format of the geometries. For now, we vendor an implementation of geo-traits (see [mod@geo_traits]), but this may be upstreamed to georust in the future.

use geoarrow::array::PointArray;
use geoarrow::datatypes::Dimension;

let point = geo::point!(x: 1., y: 2.);
let array: PointArray = (vec![point].as_slice(), Dimension::XY).into();

Or you can use builders, e.g. PointBuilder:

use geoarrow::array::PointBuilder;
use geoarrow::datatypes::Dimension;

let mut builder = PointBuilder::new(Dimension::XY);
builder.push_point(Some(&geo::point!(x: 1., y: 2.)));
let array = builder.finish();

Dependencies

~23–49MB
~839K SLoC