tmontaigu / shapefile-rs

Rust library to read & write shapefiles
MIT License
59 stars 19 forks source link

Make geo_types directly Writable and Readable without having to use Convertions #22

Open tmontaigu opened 3 years ago

tmontaigu commented 3 years ago

This might not be possible as some geotypes are not compatible / has no shapefile equivalent, but should still be looked into

tmontaigu commented 3 years ago

What is this geozero thing, and could it be used/implemented ? 🤔

michaelkirk commented 3 years ago

I've used geozero just a bit, but haven't used the shapefile features. If you haven't already found it, there is some support for reading (but not yet writing) shapefiles https://github.com/georust/geozero/blob/master/geozero-shp/src/shp_reader.rs

The reading support leverages your dbase crate.

If you have questions, the primary author @pka might be able to help.

pka commented 3 years ago

Converting between formats without intermediate representation is the primary goal of geozero. The mentioned driver is a stripped down version of shapefile-rs which supports reading shapefiles and converting to geo_types, but also to GeoJSON, WKT, GEOS, GDAL and others. But the other direction is not supported and not high on the priority list. If there is a idea for collaboration, I'm open for it.

tmontaigu commented 3 years ago

I wanted to explore the possibility of reading and writing directly to geo_types without going through conversions between shapefile-rs types and geo_types as I think geo_types are often used.

Implementing that using geozero, if I understand correctly, would give more flexibility in the output type of the reader however I also need the ability to write and I'd like this to be an optional feature

worace commented 3 years ago

I'm interested in following the discussion here as well as I've started trying to use this library to add shp reading to https://github.com/worace/geoq.

1 thing that I've run into a lot when working in the geo rust ecosystem is that geo_types coordinates only support x and y. With that limitation, I think you are always going to need some additional set of types to handle the Z and M variants, right?

I was looking at similarly reading shp -> geojson, and while I could potentially rely on the shapefile -> geo_types conversions shipped with this library to go shp -> geo_types -> geojson, it would only work for the 2d variants. So I think I may end up doing the whole shp -> geojson matching myself for the sake of handling as many geom types as possible.

worace commented 3 years ago

geozero is new to me as well; I will need to spend some time reading up on that. But from a quick scan it looks like it does support the dimensions needed at least. Maybe that would be a better fit for the kind of things I'm doing as well.