5

I'm trying to import a TIF raster into a Postgres db using this command:

Raster2pgsql -s 26591 -I -C -e -Y -F –N -M C:\Users\Ivn\Desktop\Postgre_HOME\scratchmres1.tif -F | psql -U postgres -d ivndb -h localhost -p 5432

the command works but I can't add to display the raster in QGIS 2.10 PISA, I get the following warning:

enter image description here

And this messages in the registry:

PG: dbname=ivndb host=localhost port=5432 mode=2 schema=public column=rast table=geodb è un layer non valido - non

Can someone help me?

SOLVED! @Steven kay enter image description here

  • It will probably be helpful if you can include the error in the text of the post as well as the picture. This will make it searchable. Also, it looks like it's complaining about an invalid layer, but a translation would be good as well. – Evil Genius Oct 11 '15 at 12:59
  • I could reproduce this (Qgis 2.10.1) . Error in English is "geodb is an invalid layer - not loaded". Running qgis from terminal and looking at the console, I also saw this :- ERROR 1: User parameter must be provided, or PGUSER environment variable must be set. Please set the user and try again.. – Steven Kay Oct 13 '15 at 13:03
2

Confimed (Ubuntu Pisa 2.10.1, 32 bit Ubuntu)

This might be a bug in Database Manager.

If you're on Ubuntu you can launch QGIS and see some additional error messages not available through the GUI. I saw this...

ERROR 1: User parameter must be provided, or PGUSER environment variable must be set. Please set the user and try again.

If you look at your log you'll see the GDAL Url which has been built to access the raster. It should look something like

PG: dbname=rastertest host=127.0.0.1 port=5432 mode=2 schema=public column=rast table=mytable

There's no username or password in that URL, I suspect this is the problem.

I thought that maybe those were redacted (hidden), but it looks like they're not being sent to the GDAL Driver.

Good news, though - you can work around it. Copy and paste the URL from the Error Log, and paste it into a text editor. Add your username and password, like so

PG: dbname=rastertest host=127.0.0.1 user=scott password=tiger port=5432 mode=2 schema=public column=rast table=mytable

Now, go to the Python console and import it from there...

rl = QgsRasterLayer("PG: dbname=rastertest host=127.0.0.1 user=scott password=tiger port=5432 mode=2 schema=public column=rast table=mytable", "testlayer")
QgsMapLayerRegistry.instance().addMapLayer(rl)

That should allow you to pull the image out of the database. If no layer is added, make sure all your parameters are correct. If any of them are wrong, it won't throw an exception.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.