Saturday 9 February 2019

How to view a postgis raster query in QGIS


I have successfully loaded a large number of .asc images (>2800 200x200 tiles) into a Postgres table with PostGIS 2.1 support. The new table appears in QGIS's DB Manager and I can add the whole image as a single layer.


Is there a way, for example, to create an SQL script on raster tables and display the result in QGIS as a raster layer as you might with a vector layer? Or simply to filter the table to specific tiles.



Within QGIS, the DB Manager allows me to load the whole table but doesn't seem to support filtering of the table, and neither does right clicking on the layer once its loaded.


This is my first foray into PostGIS and rasters so the answer may be obvious so please have patience with me.



Answer



You can't quite do an SQL script, however you can create a database view via DbMAnager or pgAdmin or psql, and then from DbManager drag that raster view unto QGIS Map.


Also as I recall, I don't think the newer versions of QGIS try to load the whole table, so if you have your map set already, it should load just enough to fit in that area. It will also take advantage of overview tables for performance speedup.


So when you load raster data, make sure to do it with the -l option to build overview tables.


http://postgis.net/docs/manual-2.1/using_raster_dataman.html#RT_Raster_Loader


In 2.2 we should have some functions that also allow you to do that for data already in the db.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...