QGIS – Not Showing SQL Geometry

Marketing
Marketing
  • Updated

by David Crowther

SQL Geometry 1.png

Question:

Why is the geometry of my data stored in a SQL Database not showing in QGIS?

Answer:

There can be multiple reasons why you are not seeing the features from your SQL Tables in QGIS. This blog below discusses the use of the geometry_columns table for connecting QGIS to tables in a database, so is a good place to start.

https://www.cadlinecommunity.co.uk/hc/en-us/articles/6873414892317-QGIS-Geometry-Columns-Table

When you wish to open a layer with multiple geometry types e.g. a GM_PLOTS table that contains Points, Lines and Polygons, you will need to make changes to the geometry_columns table in your source database each time you connect to the database table, so you can open 3 layers with each type of individual geometry. We do this by editing the geometry_type value in this table to open each of the 3 geometry types 1 by 1 into QGIS.

  • LINESTRING
  • POLYGON
  • POINT
  • (and Multi types as needed)

SQL Geometry 2.jpg

However, sometimes you can do this and for some reason only the POLYGON geometry shows,.. the LineString ad Point layers open, but no geometry is shown!

One possible reason for this is that the value for the geometry field stored in the f_geometry_column is CASE SENSITIVE!, so even if you have correctly spelt the tables geometry field name,.. if you have incorrectly typed a character in the wrong case,.. the data table will open into QGIS, but the geometry won’t be shown in the map.

SQL Geometry 3.jpg

So, correct the spelling or Case of the geometry field and try again – for me, this then correctly opened the LINESTRING and POINT geometry into QGIS!

 

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.