georust / geozero

Zero-Copy reading and writing of geospatial data.
Apache License 2.0
336 stars 33 forks source link

feature: convert GeozeroDatasource to geo package #38

Open michaelkirk opened 2 years ago

michaelkirk commented 2 years ago

I see there is some support for encoding/decoding geometry with geo-package: https://github.com/georust/geozero/blob/master/geozero/src/gpkg/geopackage.rs

How about a one-shot conversion of a GeozeroDatasource to convert geometry and feature data to geo package format?

let mut filein = BufReader::new(File::open("countries.fgb")?);
let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
fgb.write_gpkg("contries.gpkg").unwrap();
pka commented 1 year ago

Would definitely be nice to have. It requires more than WKB encoding, which is already available. You have to issue SQL statements for creating tables and inserting properties together with the geometry. And the code should be similar for PostGIS output.

Example for property+geometry insertion: https://github.com/georust/geozero/blob/4ec8eba5831c86000f28ee9eb57f9dfb95af957d/geozero/tests/postgis.rs#L215-L220