Feature request #3645

synchronize QGIS' SRS definitions with GDAL's 1.8.0 SRS database

Added by Mathieu Pellerin - nIRV over 9 years ago. Updated over 9 years ago.

Status:Closed
Priority:Low
Assignee:Jürgen Fischer
Category:Projection Support
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13704

Description

Some QGIS´ SRS definitions are missing towgs84 values, including UTM Indian 1960 48N, resulting in misalignment of mixed-datum layers with projects with on the on the fly reprojection set.

Folks from the #gdal IRC channel said QGIS should update/synchronize it's SRS definition database with GDAL's 1.8.0 SRS database.

I can confirm that creating a custom SRS using GDAL's version of the UTM Indian 1960 48N definition (same as QGIS except QGIS misses the +towgs84 value) fixed all of my reprojection problems.

(see a bunch of screenshots with misaligned vectors from this now invalid ticket: http://trac.osgeo.org/qgis/ticket/3632)

Pasting some useful bits from a discussion in #gdal:
<nIRV> EvenR, what would explain a difference in reprojection between qgis and gdal?
<EvenR> it might depend on the GDAL version you have and the definition that QGIS uses for EPSG:3148. GDAL 1.8.0 has a TOWGS84[198,881,317,0,0,0,0] for EPSG:3148.
<EvenR> you have to check what SRS definition qgis uses for EPSG:3148. I suspect it has not the TOWGS84 shift
<nIRV> +proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +units=m +no_defs
<nIRV> indeed, there's no towgs84 in the qgis definition
<EvenR> it could be appropriate that it synchronizes its SRS definitions (for that one, and also for others) with GDAL 1.8.0 SRS database
<EvenR> in GDAL 1.8.0, a lot of TOWGS84 have been added by taking into account the preferred datum shift from the EPSG database
<nIRV> omg, it actually works
<nIRV> I created a custom crs using the indian 1960 48n definition and adding the +towgs84 bit, et voila
<EvenR> you can point to http://trac.osgeo.org/gdal/changeset/18978 which is the changeset during GDAL 1.8.0 where the datum shift logic has been improved

srs_sync_gdal_part1.sql (214 KB) Mathieu Pellerin - nIRV, 2011-03-21 01:39 AM

srs_sync_gdal_part2.sql (171 KB) Mathieu Pellerin - nIRV, 2011-03-21 01:40 AM

update.php Magnifier (883 Bytes) Mathieu Pellerin - nIRV, 2011-03-22 02:57 AM

crs-syncdb.diff Magnifier - patch to introduce crssync for synchronization on install (12.6 KB) Jürgen Fischer, 2011-03-27 09:00 AM


Related issues

Related to QGIS Application - Bug report #4037: Wrong CRS definition Closed 2011-06-30

History

#1 Updated by Mathieu Pellerin - nIRV over 9 years ago

  • Status changed from Open to In Progress

I created a tiny script to a) flag the srs.db's tbl_srs 'parameters' column needing updates and b) ouput the sql update query.

The script compared qgis' srs.db against the proj4's EPSG file (http://trac.osgeo.org/proj/browser/trunk/proj/nad/epsg), the latter already synched with GDAL.

2157 SRS parameters needed update (mostly +towgs84 additions).

#2 Updated by Mathieu Pellerin - nIRV over 9 years ago

I've attached the script used to come up with the sql update statements. It's unfortunately not in python but in php.

#3 Updated by Jürgen Fischer over 9 years ago

the attached patch updates our db with the parameters of PROJ. This could be run on automatically at installation (using the python API).

Unfortunately there currently is a bug in PROJ that causes the routine to crash after fetching 16 projections (PROJ #100).

#4 Updated by Mathieu Pellerin - nIRV over 9 years ago

jef, as mentioned over irc, the updated srs.db you applied in changeset 15584 (http://trac.osgeo.org/qgis/changeset/15584) doesn't appear to have the latest definition for many datums (based in gdal 1.8).

To give one example, the epsg 3148 (indian 1960 48n) in your srs.db is:
+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +units=m +no_defs

It's missing the +towgs84 declaration, found in latest gdal 1.8 and proj.4 epsg file:
+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +towgs84=198,881,317,0,0,0,0 +units=m +no_defs

Without the +towgs84 declaration, on the fly reprojection of wgs84 & epsg 3148 datums have a +450m margin difference. It also affects coverting layers from one datum to the other using qgis' built-in "save as..." function.

You based your updated srs.db on proj 4.7.0 (http://trac.osgeo.org/proj/browser/tags/4.7.0/proj/nad/epsg) which the devs synched with latest gdal definitions afterwards (http://trac.osgeo.org/proj/browser/trunk/proj/nad/epsg).

Would it be possible to ship 1.7 with a srs.db synched with gdal latest datum definitions?

#5 Updated by Maciej Sieczka - over 9 years ago

Replying to [comment:4 nirvn]:

Would it be possible to ship 1.7 with a srs.db synched with gdal latest datum definitions?

Couple of months ago I have written a Shell script which creates a new srs.db based on the output of localy installed PROJ.4 and GDAL: http://trac.osgeo.org/qgis/browser/trunk/qgis/scripts/qgis_srs.sh.

It was used once to update the srs.db in SVN, about a year ago. After that, a few manual edits have been done on srs.db too.

The script would not retain those manual non-GDAL-derived SRS definitions. They would need to be taken care of. I guess that as of current trunk SVN these are srs_id>=3646.

#7 Updated by Paolo Cavallini over 9 years ago

Now EPSG:3003 is defined in QGIS as:

+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl
+towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs

instead of the old:
+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl
+no_defs

Similarly for EPSG:3004.

The corrections have been already inserted as fake EPSG codes:

40000
+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl
+units=m +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +no_defs
40001
+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl
+units=m +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +no_defs
40002
+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl
+units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs
40003
+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl
+units=m +towgs84=-50.2,-50.4,84.8,-0.690,-2.012,0.459,-28.08 +no_defs

So the fake codes 40000 and 40001 are now duplicates, and should be
removed. 40002 and 40002 are useful, as they define ad hoc datum for
Sardinia and Sicily.

#8 Updated by Jürgen Fischer over 9 years ago

Replying to [comment:7 pcav]:

So the fake codes 40000 and 40001 are now duplicates, and should be
removed. 40002 and 40002 are useful, as they define ad hoc datum for
Sardinia and Sicily.

The EPGS numbers are prefered. Removing the definitions might break layers that are assigned to one of those.

#9 Updated by Jeremy Palmer over 9 years ago

The patch from http://trac.osgeo.org/qgis/ticket/3136 have also been reverted by this update from gdal. Can we re-apply them?

#10 Updated by Jürgen Fischer over 9 years ago

  • Status changed from In Progress to Open

#11 Updated by Jürgen Fischer over 9 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

applied in a9aafd07

Also available in: Atom PDF