Thoughts on PROJJSON for CRS encoding? #90
Replies: 9 comments 10 replies
-
Ok, since I kind of started this discussion. Here's my take. I think a lot of the posturing for or against CRS metadata is due to WKT2 being poorly suited for what geospatial file formats and data transports need from CRS interoperability. I think it was the same thing with GeoJSON, but there was no full-featured WKT2 library at that time, which really tilted us away from imposing its full complexity on all implementors as a requirement. I think @kylebarron's description of the terrible parts of WKT2 being both parsing and interpretation is accurate, and PROJJSON conveniently addresses the parsing and syntax validation in combination with JSON Schema usage. This means that applications can at least be protected against propagating junk syntax definitions. Kyle's point about being able to write nonsense definitions that still syntax validate is always true, and the data model what WKT or PROJJSON describes is going to complex no matter its container. Another +1 for PROJJSON is applications can peek into it and consume parts that they do know. It's tough to do that with WKT because of the parsing and validation challenge. The definitions are conveniently available, so answers to questions of the CRS like "Is this a geographic one?" or "What are the X and Y units?" are possible with some JSON walking/scanning. Doing that with WKT means writing some awful regexs, writing a parser, or pulling in a giant dependency like PROJ. It also would be nice if someone could take PROJJSON through the OGC Community Specification process so it could be referenced. That's a money/time/desire request, but some kind of alternative encoding CRS definition is needed to sidestep WKT's problem of requiring custom parsers, and PROJJSON uptake by other specs likely requires/desires that kind of referencing. @rouault made PROJJSON partly to see if it could work and partly to start a discussion about WKT's failures, but maybe now is the time to get more serious about its uptake. |
Beta Was this translation helpful? Give feedback.
-
I'd be obviously supportive of PROJJSON, and concur with @hobu and @kylebarron above remarks. |
Beta Was this translation helpful? Give feedback.
-
I am generally positive on the idea to move to PROJJSON. I think it would be a nice improvement in usability (easier to check eg the id of a "crs", without the need to have a full WKT parser). From GeoPandas' point of view, this is also fine because we rely on PROJ (through It would be good to hear what the impact of moving to PROJJSON would be for some other implemenations? |
Beta Was this translation helpful? Give feedback.
-
I'm 👍 on trying PROJJSON as a replacement for WKT2. This seems like it addresses the shortcomings of making WKT required for common use cases around geographic coordinates but still provides the ability to clearly document the CRS, and since folks will have to parse JSON anyway, this is probably even better. |
Beta Was this translation helpful? Give feedback.
-
I like the idea of PROJJSON in GeoParquet metadata...while somebody doing coordinate transforms will almost certainly be using PROJ in some way (thus WKT is fine), there are some questions like "are the coordinates longitudes and latitudes?" and "can we consider this CRS equal to this other CRS?" that PROJJSON facilitates in a way that WKT2 doesn't. Probably the most useful thing that can be done with PROJ JSON that is difficult to do with WKT is to print out a compact definition of the CRS for a user to read. From a 'geoarrow' encoding perspective, we're (currently, depending on geoarrow/geoarrow#17) stuck with a single level of key/value metadata where the value has to be a string. One thread has probed at the idea of allowing multiple CRS encodings (geoarrow/geoarrow#8), so there's no reason a PROJJSON string couldn't be one of the types. The set of C++ headers that power the 'geoarrow' R package could probably include enough parsing capability to at least extract WKT and/or JSON into C++ structures that can be inspected (if not interpreted to the extent that the PROJ WKT parser is able to do). |
Beta Was this translation helpful? Give feedback.
-
I'm 👍 too with the idea of PROJJSON |
Beta Was this translation helpful? Give feedback.
-
+1 with PROJJSON. I've already shared my thoughts about this issue in #52 (comment) |
Beta Was this translation helpful? Give feedback.
-
@rouault to what extent would a json object like It's not valid, because it is missing a bunch of required fields (following the JSON schema). And I suppose it also doesn't make much sense because PROJJSON (or WKT) is meant to describe the actual information you need to know instead of having to rely on some (database) source to look up that information for an authority/code? The reason that I was wondering the above is to understand to what extent using PROJJSON could also help the desire of some people to only use an authority:code combo. |
Beta Was this translation helpful? Give feedback.
-
I've just submitted enhancements to the PROJJSON specification in OSGeo/PROJ#3190 . Feedback welcome. It is hard to find the right balance between being exhaustive (which require a ~ 100 page document like the WKT CRS spec) and not saying enough. I've tried to concentrate on the gaps / particularities of the JSON encoding compared to the WKT one |
Beta Was this translation helpful? Give feedback.
-
I'm not an expert by any means on CRS, but I'd be interested in hearing others' thoughts about requiring PROJJSON instead of (or as an optional counterpart to) a WKT2 string.
Benefits:
According to the PROJJSON spec, "PROJJSON is a JSON encoding of WKT2:2019". So in effect it's the same metadata we already require, but stored as JSON instead of as a WKT string.
A stated issue with requiring CRS information is that the WKT string is hard to parse. From Should we recommend EPSG:4326 or something else? #52 (comment):
Using PROJJSON instead of WKT could at least remove the difficulty of parsing the CRS information, though the difficulty of interpreting the parsed information would remain.
The rest of our metadata is already stored as JSON. So we already expect readers and writers to be able to handle JSON.
PROJ defines a PROJJSON schema: https://proj.org/schemas/v0.4/projjson.schema.json. We would be able to reference that schema within our own JSON Schema definition, and so be able to validate our own metadata and CRS in one go. (Though I assume it's possible to create a PROJJSON string that validates against the schema but is non-sensical?)
Might be easier to support than WKT2 for proj4.js: Support for PROJJSON proj4js/proj4js#400 (comment)
Drawbacks:
References:
Beta Was this translation helpful? Give feedback.
All reactions