GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.09k stars 259 forks source link

Interest in I/O methods interfacing geopandas objects? #270

Open martinfleis opened 4 months ago

martinfleis commented 4 months ago

Hi all,

a while ago, when we considered providing pure Python I/O in GeoPandas, I have drafted read and write functions to and from GeoDataFrames to shapefile using pyshp. We decided not to go that way in the end but I was wondering if you might be interested in including it here before I'll simply dump it to a Gist and forget about it.

You can check the implementation here https://github.com/geopandas/geopandas/pull/1580 . It may be a little dated but should likely work. I am happy to turn it into a PR if you consider it worthwhile, but I am also happy to let it go.

JamesParrott commented 4 months ago

Thanks for this Martin.

Is the essence of it the two read and write functions in the attached file?

It pulls in pyproj and chardet, but the encoding fallback and cpg support would be useful - (issue #247 requested support for cpg files).

PyShp shouldn't pull in geopandas by default, so It'd need an optional extra install on PyPi. PyShp's setup.py is a nice simple two liner at the moment.

The functions are well worth putting on a branch though, as people can install that straight from github with pip now.

PyShp_read_write_Geodataframe.zip

JamesParrott commented 4 months ago

I've thrown this together (and have not tested it):

https://github.com/JamesParrott/IronPyShp/tree/PyShp-read-write-Geopandas-DFs

martinfleis commented 4 months ago

Is the essence of it the two read and write functions in the attached file?

Yes, it should work in the same way you included it in https://github.com/JamesParrott/IronPyShp/tree/PyShp-read-write-Geopandas-DFs. Might need minor touches to accommodate for the latest API changes here and there but I don't expect much.

It pulls in pyproj and chardet PyShp shouldn't pull in geopandas by default

Agree, all those shall be soft-dependencies here.