rouault / projjson_to_wkt

Python library to convert a PROJJSON string to WKT
MIT License
5 stars 1 forks source link

WKT -> PROJJSON #1

Open kylebarron opened 2 years ago

kylebarron commented 2 years ago

👋 Hi Even, awesome work on this.

I've been looking through the code and thinking about trying to write an implementation that converts from WKT to PROJJSON. I think a pure-Python example of this could partly assuage some PROJJSON interoperability concerns, e.g. in https://github.com/geopandas/geo-arrow-spec/issues/8#issuecomment-1164285103.

My thinking is that I'd implement a WKT parser (prior pure-Python art here https://github.com/karimbahgat/PyCRS/blob/master/pycrs/parse.py#L136-L423) and then attempt to follow your code for the inverse mapping of tags from WKT into PROJJSON (probably first starting just with WKT2 and then maybe later with WKT1).

Would you be interested in a PR to this repo? Or would you prefer to keep this repo minimal with just PROJJSON -> WKT?

rouault commented 2 years ago

Would you be interested in a PR to this repo?

make sense.

Note that the PROJJSON -> WKT1 in the existing code is more a toy than something actually useful. It produces syntaxically valid WKT1, but the issue is that real interoperability comes with projection method and parameter names, datum names, etc. and traditionnaly WKT1 in GDAL <= 2.4 uses quite different names from the one of WKT2 with latest EPSG database, and this more or less requires a full PROJ implementation to do those non-trivial morphing. So you'd better restricting your scope to WKT2:2019 -> PROJJSON.