.shp to .geojson with geozero_shp

Hello, the geozero_shp crate says that it supports converting to GeoJSON but there is no example of how to do so in the docs. Does anyone have experience working with this crate or does anyone know how to use it to do such a thing? It looks like it involves using geozero alongside geozero_shp...?

use geozero::geojson::GeoJsonWriter;

fn main() {
    let path = "C:\\Users\\mthel\\Julia\\src_data\\Map Shape Files\\BLM_CO_ST_BNDY_SHP\\BLM_CO_ST_BNDY_20170109.shp";
    let reader = geozero_shp::Reader::from_path(path).unwrap();
    let mut json: Vec<u8> = Vec::new();
    let data = reader.iter_features(GeoJsonWriter::new(&mut json)).unwrap();
}

data is a ShapeRecordIterator but how do I go from that to geoJSON???

ShapeRecordIterator implements FeatureProcessor, which can be written by GeoJsonWriter: geozero::geojson::GeoJsonWriter - Rust. Does that get you any further? GeoRust has a dedicated Discord (GeoRust) – the GeoZero author is active there and very responsive to questions (ping @pka in the main channel)

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.