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.52k stars 2.99k forks source link

Custom CRS recognized as Unknown when defined by proj4 string #36688

Closed caprieldeluca closed 4 years ago

caprieldeluca commented 4 years ago

Describe the bug

When a custom CRS is added from a proj4 string, the WKT definition is not saved in the tbl_srs table of the qgis.db database. When exporting a layer to the new system an loading it, it is recognized with Unkown CRS system.

How to Reproduce

  1. Create a new custom CRS with the following proj4 string: +proj=tmerc +lat_0=-34.6297166 +lon_0=-58.4627 +k=0.999998 +x_0=100000 +y_0=100000 +ellps=intl +towgs84=-148,136,90,0,0,0,0 +units=m +no_defs
  2. Export any layer to the new CRS and load it. The layer CRS property is recognized as Unknown CRS.
  3. In the Custom Projections dialog, change the format of the definition to WKT.
  4. Reload the layer. The layer CRS property is recgnized with USER code and name

QGIS and OS versions

QGIS 3.10.5 at Windows 10 (64-bit) machine, OSGeo4W install.

Additional context

In the tbl_srs of qgis.db database, the WKT definition is stored only when the format of the definition in the custom CRS is changed to WKT.

Screenshots

1-1-customCRS

1-2-qgisdb

1-3-layerProperties

2-1-customCRS

2-2-qgisdb

2-3-layerProperties

nyalldawson commented 4 years ago

This is a wont-fix, as it's working as designed. It's not possible to reliably match proj strings to user CRSes defined by proj strings without a LOT of unexpected/dangerous side effects.

Proj strings are a lossy format, discouraged for use in modern workflows. Just don't use them, and use WKT instead.