[GIS] How to change an existing srs in QGis

coordinate systemepsgqgissrid

I am showing postgis data with srid 28992 (Amersfoort / RD New). But when I plot the geospatial data on a map (with openlayers plugin), the data is shown a hunderd meters off because the datum shift is not taken into account.

When I make a custom CRS with the correct datum shift and set my layer to that CRS is it shown correctly.

I want to update QGis' standard interpretation of 28992 so it takes into account this datum shift (+towgs84 parameter) correctly and when I open new data it is shown correctly immediately.

I found that QGis has a sqlite db called srs.db in /usr/share/qgis/resources/. But even when I update the record for 28992 it still doesn't show the data correct on the map. When I inspect the layer in QGis I see it still has no +towgs84 parameter.

Does this mean that QGis does not actually use this sqlite db? Because the data I show is from a postgresql database I also edited spatial_ref_sys.sql to make sure that it also knows about the datum shift.

I also edited the epsg en esri files in /usr/share/proj/ just to be sure, but no effect.

At this moment I cannot think of another place where QGis gets its projection information from.

Best Answer

Are you sure that your Postgis and QGIS share the same +towgs84 parameters?

My QGIS 2.0.1 Dufour comes with this definition:

+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs

while my PostgreSQL has this stored in table spatial_ref_sys

+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812 +units=m +no_defs

If your QGIS has another proj definition for EPSG:28992, your installation might be broken. Have a look at the setup log if postinstall was broken somewhere.

One other point: Postgis uses this string for the WKT definition:

PROJCS["Amersfoort / RD New",
  GEOGCS["Amersfoort",
    DATUM["Amersfoort",
      SPHEROID["Bessel 1841",6377397.155,299.1528128,
      AUTHORITY["EPSG","7004"]],
    AUTHORITY["EPSG","6289"]],
    PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4289"]],
    UNIT["metre",1,AUTHORITY["EPSG","9001"]],
  PROJECTION["Oblique_Stereographic"],
    PARAMETER["latitude_of_origin",52.15616055555555],
    PARAMETER["central_meridian",5.38763888888889],
    PARAMETER["scale_factor",0.9999079],
    PARAMETER["false_easting",155000],
    PARAMETER["false_northing",463000],
    AUTHORITY["EPSG","28992"],
    AXIS["X",EAST],
    AXIS["Y",NORTH]]

which references to Amersfoort datum, but no +towgs84 are stored for that. I am not sure if QGIS therefore sets +towgs84 to zero, instead of using its own EPSG values, or those from the Postgis proj4 string.

QGIS writes this .qpj output:

PROJCS["Amersfoort / RD New",
  GEOGCS["Amersfoort",
    DATUM["Amersfoort",
      SPHEROID["Bessel 1841",6377397.155,299.1528128,
      AUTHORITY["EPSG","7004"]],
    TOWGS84[565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725],
    AUTHORITY["EPSG","6289"]],
    PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4289"]],
PROJECTION["Oblique_Stereographic"],
  PARAMETER["latitude_of_origin",52.15616055555555],
  PARAMETER["central_meridian",5.38763888888889],
  PARAMETER["scale_factor",0.9999079],
  PARAMETER["false_easting",155000],
  PARAMETER["false_northing",463000],
  UNIT["metre",1,AUTHORITY["EPSG","9001"]],
  AXIS["X",EAST],
  AXIS["Y",NORTH],
  AUTHORITY["EPSG","28992"]]
Related Question