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:
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?
Answer
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.
No comments:
Post a Comment