pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.06k stars 214 forks source link

ENH: allow to check for specific WKT flavor in the is_wkt() function #1031

Open jorisvandenbossche opened 2 years ago

jorisvandenbossche commented 2 years ago

There is a is_wkt function that allows you to check if a given string is a WKT string:

https://github.com/pyproj4/pyproj/blob/2d3cc7e0b83f59df2c0f5d3c2a8446ce0f224700/pyproj/_crs.pyx#L32-L48

The proj method it is using for that (proj_context_guess_wkt_dialect) should also allow to check for an exact flavor. So there could be an optional version keyword, to allow something like is_wkt(..., version="WKT2_2019")?

snowman2 commented 2 years ago

Yes, that is possible to check for a specific version: https://proj.org/development/reference/datatypes.html#c.PJ_GUESSED_WKT_DIALECT

Another alternative could be to add a new function that returns the WKT version.

snowman2 commented 2 years ago

Thoughts on adding a new method called something like guess_wkt_version that returns the WktVersion or None if it is not a WKT?