qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.58k stars 3k forks source link

ESRI/EPSG codes mismatch on export>Save Features As... #50419

Closed mapninja closed 2 years ago

mapninja commented 2 years ago

What is the bug or the crash?

Exporting a shapefile using ESRI:102999 results in a shapefile withEPSG:6419 CRS defined.

Steps to reproduce the issue

Exporting an EPSG:4269 shapefile to a new shapefile using ESRI:102999 - NAD_1983_2011_StatePlane_California_III_FIPS_0403 as the output CRS results in a shapefile with EPSG:6419 - NAD83(2011) / California zone 3 as it's CRS. Not a show stopper, but definitely confusing and not the expected behavior.

Discovered while writing this, so here is the full workflow: https://github.com/mapninja/Earthsys144/blob/master/Labs/Week_02/Coordinate_Systems_Geodesy.md

Versions

MacOS Monterey QGIS 3.26.3

Supported QGIS version

New profile

Additional context

No response

roya0045 commented 2 years ago

Might be related to proj and handling esri's code, as I assume they might be closed source or some other limiting factor related to them.

agiudiceandrea commented 2 years ago

I can also confirm the issue on Windows with QGIS 3.22.10: when a vector layer (with any CRS) is exported as an ESRI Shapefile layer selecting the "ESRI:102999 - NAD_1983_2011_StatePlane_California_III_FIPS_0403" CRS, then the exported layer CRS is recognised by QGIS as "EPSG:6419 - NAD83(2011) / California zone 3" instead.

The exported ESRI Shapefile layer *.prj sidecar file contains the PROJCS["NAD_1983_2011_StatePlane_California_III_FIPS_0403",GEOGCS["GCS_NAD_1983_2011", ... string.

The same issue occurs when a new empty ESRI Shapefile layer is created in QGIS selecting the "ESRI:102999 - NAD_1983_2011_StatePlane_California_III_FIPS_0403" CRS: the created layer is added in the map with the "EPSG:6419 - NAD83(2011) / California zone 3" CRS instead.

The issue doesn't occur if the layer is exported e.g. as GeoPackage, GeoJSON or FlatGeobuf: in this cases the exported layer CRS is recognised by QGIS as "ESRI:102999 - NAD_1983_2011_StatePlane_California_III_FIPS_0403"

It seems to me this is a GDAL/OGR and/or PROJ issue.

rouault commented 2 years ago

EPSG:6419 and ESRI:102999 are aliases of each other. When writing a shapefile .prj, ESRI WKT must be used, and the representation of them is identical, and ESRI WKT doesn't contain a AUTHORITY:CODE. When reading back, OGR will prefer the EPSG code to the ESRI one when 2 CRS match the ESRI WKT definition, because that's more interoperable So for me works as intented, and there's not much that can be done to change that behavior.