QGIS – SQL Data Offset

Marketing
Marketing
  • Updated

by David Crowther

DC_QGIS_SQL_01.png

Question:

When opening my SQL Spatial Layer into QGIS, the features appear offset/shifted. However, when shown as spatial data in my webGIS or via GeoServer the features are in the correct location – what is causing this shift?

Answer:

This issue could be related to using a newer version of QGIS, where it is not quite recognising the CRS of the SQL Table and so applies an incorrect or older Transformation.

In QGIS, there are a number of options to edit the default Projection (CRS) Settings for QGIS – Settings > Options > CRS:

Here you can define the CRS for:

  • New Projects
  • Layers

DC_QGIS_SQL_02.jpg

Working in the UK, we would recommend that these are set to EPSG:27700/BNG.

However, even with these settings chosen, if you add a Table from SQL, QGIS will implement a Transformation to render this onto the map. There are a number of Transformation options for EPSG:27700 with more accurate Transformations added each year.

So, even if your source SQL Table has a SRID applied:

DC_QGIS_SQL_03.jpg

when this is opened in older versions of QGIS e.g. QGIS 2.x, the layer renders as expected in the correct location.

DC_QGIS_SQL_04.jpg

However, the exact same layer may be offset/shifted when opened into QGIS 3.16.

DC_QGIS_SQL_05.jpg

In order to correct this Transformation issue, simply open the Layer Properties > and in the Source Tab change the Assigned Coordinate Reference System (CRS) to override the Layers CRS and apply the correct CRS as required.

DC_QGIS_SQL_06.jpg

Here we can see that the Layer has a current assigned CRS of OSGB 1936/BNG – but we want to change that to a newer and more accurate Transformation of EPSG:27700 – OSGB 1936/BNG.

DC_QGIS_SQL_07.jpg

Once you Apply that change, the layers transformation in the map will be correctly applied and the offset/shift is resolved.

DC_QGIS_SQL_08.jpg

If you save your QGIS Project > the Transformation for that SQL Table will be applied and the layer will open in the correct location.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.