#geojson #gis #json #geo

geojson

Library for serializing the GeoJSON vector GIS file format

36 releases (18 breaking)

✓ Uses Rust 2018 edition

new 0.18.0 Mar 23, 2020
0.17.0 Dec 28, 2019
0.16.0 May 5, 2019
0.15.0 Feb 17, 2019
0.0.1 Dec 4, 2014

#4 in Science

Download history 718/week @ 2019-12-02 2595/week @ 2019-12-09 694/week @ 2019-12-16 237/week @ 2019-12-23 577/week @ 2019-12-30 796/week @ 2020-01-06 1119/week @ 2020-01-13 1035/week @ 2020-01-20 805/week @ 2020-01-27 779/week @ 2020-02-03 1008/week @ 2020-02-10 1355/week @ 2020-02-17 1110/week @ 2020-02-24 1506/week @ 2020-03-02 1557/week @ 2020-03-09 1328/week @ 2020-03-16

4,481 downloads per month
Used in 30 crates (22 directly)

MIT/Apache

155KB
2K SLoC

geojson

Documentation

Library for serializing the GeoJSON vector GIS file format

Minimum Rust Version

This library requires a minimum Rust version of 1.34 (released April 11 2019)

Examples

Reading

use geojson::GeoJson;

let geojson_str = r#"
{
    "type": "Feature",
    "properties": {
        "name": "Firestone Grill"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [-120.66029,35.2812]
    }
}
"#;

let geojson = geojson_str.parse::<GeoJson>().unwrap();

Writing

use geojson::{Feature, GeoJson, Geometry, Value};
use serde_json::{Map, to_value};

let geometry = Geometry::new(
    Value::Point(vec![-120.66029,35.2812])
);

let mut properties = Map::new();
properties.insert(
    String::from("name"),
    to_value("Firestone Grill").unwrap(),
);

let geojson = GeoJson::Feature(Feature {
    bbox: None,
    geometry: Some(geometry),
    id: None,
    properties: Some(properties),
    foreign_members: None,
});

let geojson_string = geojson.to_string();

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.5–0.8MB
~17K SLoC