[PROJ] Unexpected CRS Validation Error
Even Rouault
even.rouault at spatialys.com
Thu Mar 28 08:10:23 PDT 2024
Hi,
just a few complements to Javier's analysis:
- what you observe and what Javier mentioned applies if you import
directly the .prj WKT content, but the GDAL shapefile driver actually
replaces this not pretty WKT with a cleaned version of EPSG:4326 (at
least with GDAL+PROJ master), so if you use the high level GDAL API,
things should work smoothly
- the 9001 ID you observe when looking at the WKT2 output of the result
of the ingestion of the .prj is *not* a CRS ID. It is the ID of the
ellipsoid's lengthunit=metre. You can have several IDs in a WKT
definition: for the CRS, datum, ellipsoid, projection method, projection
parameter, units, etc. They only apply to the node to which they are
applied to. In some contexts, they are advised to be omitted. The
general rule is "if you know the id of a top-level object, you can omit
the IDs of its child elements, except in several cases". All gory
details at https://www.ogc.org/standard/wkt-crs/
So all in all, to me things are working as expected. It is mostly you
deal with a a slightly non-compliant .prj file
Even
Le 28/03/2024 à 03:06, Simon Eves via PROJ a écrit :
> When trying to import this Shapefile bundle into our system with GDAL...
>
> https://drive.google.com/file/d/13Mwhnugcy8HrnGlc81gyroxnp9s15Skt/view?usp=sharing
>
> ...we get an *OGRERR_CORRUPT_DATA* from
> *OGRSpatialReference::Validate()* on the SR obtained from the first
> feature.
>
> Tracing through the GDAL and PROJ code, this appears to be because the
> PROJ import of that CRS results in the following WKT Import Error from
> PROJ...
>
> /Coordinate system of GeographicCRS in the WKT definition is different
> from the one of the authority. Unsetting the identifier to avoid confusion
> /
>
> ...and any WKT Import Error makes GDAL report that error code.
>
> The PROJ code throws this in *WKTParser::Private::buildGeodeticCRS*
> (io.cpp:3229 in 9.3.0) which is old code (although the second branch
> which can throw the same error was seemingly added between 8.2 and 9.3
> in https://github.com/OSGeo/PROJ/pull/3274 ...but it's the first
> branch that's triggering in this case).
>
> *ogrinfo* on the Shapefile reports no errors or warnings, although it
> does report a CRS ID of 9001 even though it reports WGS84 elsewhere in
> the CRS block.
>
> I was able to trivially *ogr2ogr* it to GeoJSON, also with no errors
> or warnings, and that imports with no issue.
>
> Is there an actual problem (a bad file) here, or are we doing
> something wrong?
>
> Thanks, as ever, in advance.
>
> --
> Simon Eves
> Senior Rendering Engineer
> +1 (415) 902-1996
> simon.eves at heavy.ai
>
> <http://www.heavy.ai>
>
>
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/proj
--
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20240328/a04459f3/attachment.htm>
More information about the PROJ
mailing list