I am trying to run a few queries on spatial layers within a PostgreSQL/PostGIS database that I have connected to r=trough QGIS version 3.14. The queries themselves seem to run fine but I am unable t find a way of viewing the results in the QGIS map view. The 'load as new layer' option doesn't appear to work and reports 'an error creating the SQL layer'.

Can anyone advise on how to deal with this?

  • Spin up DBeaver to connect and query your database... it has a spatial results viewer that is super quick to see spatial query results. Jul 16 '20 at 17:52
  • Are you selecting the geometry column properly?
    – Techie_Gus
    Jul 16 '20 at 18:06
  • Open the PostGIS logs which are in the QGIS log panel, the small comic strip bubble bottom right corner. You will have some clues. Have check the unicity of your ID column, high probability it's the reason.
    – etrimaille
    Jul 16 '20 at 18:31
  • Thanks for the responses. Pretty sure I am using the correct 'geom' column for geometry and strangely the query itself produces a result. However the logs indicate 'Invalid PotsgreSQL Layer'. I'll have a look at DBeaver but would really like to deal with this is QGIS too since the functions all appear to be there
    – TrevP
    Jul 16 '20 at 18:39
  • The problem appears to have been that somehow I had not brought across the CRS when importing the feature into my PostgreSQL database. Re-imported and ran queries again through DB manager and all seems to have worked. Another lesson learnt
    – TrevP
    Jul 16 '20 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.