Why QGis cannot display a PostGIS raster column?
Try the following:
- Create a *.qgs file with local (grid-)data
- Open the *.qgs file with a texteritor
- Go to the line that begins with "
<datasource>
" - Change the line to: "
<datasource>PG: dbname=[DBNAME] host=[HOST] user=[USER] password=[PW] port=5432 mode=2 schema=public column=rast table=tiles where='rid = 1'</datasource>
" --> replace the square brackets! - save the file
- open it with QGIS
I hope it works
It seems QGis has a different mechanism for raster management. I am now using v3.4 LTS (w/ Postgres 10.1 and Postgis 2.4), and the issue is still present. I can say it is at the QGis side the issue resides.
It looks like raster import mechanism lacks somehow connection string to database. This is why rasters are not shown in PostgreSQL sources and we have difficulties to add this kind of layers to canvas.
Solution provided by @Marvin
works for QGis files, but it is a bit tricky and if you aim to store your project into PostgreSQL you will have to modify the ByteA
field which is definitly not a good option.
But wait, there is a hack to circonvolve this issue:
- Go to Database Manager, then raster fields are displayed as expected;
- Do not drag and drop the layer, instead right click on raster and chose Add to canvas;
- Then, you will be prompted for credentials;
- Provide it again and the raster field will be added to canvas.
Tested with DEM and Orthophoto, it is just about remind QGis for connection credentials.