<html><head></head><body><div class="ydpc9a5e406yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
<div dir="ltr" data-setdir="false">Thank you for your response Alessandro,</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">This looks good to me! Can you please tell me if this will require a QGIS build with GDAL 3+ or will it work with the 2.4 that is still being distributed for MacOS? This is true of both the LTR and Latest.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">The other issue that I have is that I have been using <span>A Coruña because of problems with PostGIS rasters in Bucharesti. </span>So far PostGIS rasters in Bucharesti are all mirrored along the bottom of the raster. The raster is upside down and does not even overlap the correct bounding box. I have not found a bug report for this on Github. I am not sure if this is peculiar to my system?</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">-Thayer</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false"><br></div><div><br></div><div>======================================================</div><div><br></div><div dir="ltr" data-setdir="false"><div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Message: 4<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Date: Thu, 30 Apr 2020 09:58:00 +0200<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">From: Alessandro Pasotti <<a href="mailto:apasotti@gmail.com" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">apasotti@gmail.com</a>><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">To: Yann Voté <<a href="mailto:ygversil@lilo.org" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">ygversil@lilo.org</a>><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Cc: qgis-user <<a href="mailto:qgis-user@lists.osgeo.org" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">qgis-user@lists.osgeo.org</a>><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Subject: Re: [Qgis-user] PyQGIS to add PostGIS raster layer?<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Message-ID:<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"> <<a href="mailto:CAL5Q672kn0MVG9eSK3eTpFW8yXpXdhMb9ykPAy-Zfm_Q11fLiA@mail.gmail.com" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">CAL5Q672kn0MVG9eSK3eTpFW8yXpXdhMb9ykPAy-Zfm_Q11fLiA@mail.gmail.com</a>><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Content-Type: text/plain; charset="UTF-8"<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">On Thu, Apr 30, 2020 at 9:46 AM Yann Voté <<a href="mailto:ygversil@lilo.org" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">ygversil@lilo.org</a>> wrote:<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> Hi,<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> Something like this should do.<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> pg_layer = QgsVectorLayer(<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> "host=db.priv.example.org port=5432 authcfg=expauth srid=4326 "<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> "dbname=exampledb table='schema'.'table_name' (geometry) "<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> "type=MULTIPOLYGON sql=",<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> baseName='table_name',<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> providerLib='postgres',<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> )<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> QgsProject.instance().addMapLayer(pg_layer)<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> Of course, adapt with your values. In particular, authcfg is the 7-chars<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> identifier of the auth configuration that contains your login and<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> password (or cert) to authenticate to PostgreSQL.<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">> See <a href="https://qgis.org/pyqgis/master/core/QgsVectorLayer.html" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">https://qgis.org/pyqgis/master/core/QgsVectorLayer.html</a><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">This won't work with rasters, you need to create a QgsRasterLayer, not<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">a vector one.<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Coming to PG rasters, in QGIS 3.12 there are two providers that<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">support PG rasters:<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">- GDAL data provider<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">- native "postgresraster" data provider<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">GDAL data source uri uses the well known good old syntax to connect to<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">the raster (you can also test the connection from the command line<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">with "gdalinfo ....").<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">The "postgresraster" provider is totally new in 3.12 and you can have<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">a look to the tests for PyQGIS use cases:<br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_provider_postgresraster.py#L82" style="color: rgb(25, 106, 212); text-decoration-line: underline;" rel="nofollow" target="_blank">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_provider_postgresraster.py#L82</a><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><br></div><div dir="ltr" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;">Hope this helps.</div></div><br></div></div></body></html>