[Qgis-user] Qgis-user Digest, Vol 171, Issue 1

Thayer Young thayeray at yahoo.com
Fri May 1 13:00:20 PDT 2020


 Yann, thank you for clarifying this for me. 
I am indeed able to add a raster in 3.12.2 using 'postgresraster' as the data provider. But I am not able to get to 'gdal' provider to work in either 3.12.2 or 3.10.5.
FYI, I believe that the raster mirroring problem that I am having in 3.12 is related to the State Plane CRS that I am using (EPSG 2893). Using UTM I do not have the same problem.
-Thayer

=============================================
Message: 2
Date: Thu, 30 Apr 2020 23:17:05 +0200
From: Yann Voté <ygversil at lilo.org>
To: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] PyQGIS to add PostGIS raster layer?
Message-ID: <a50da9d1-932d-ccb0-c26e-bd5b5f8792d2 at lilo.org>
Content-Type: text/plain; charset=utf-8; format=flowed

As Alessandro pointed out, with QGS 3.12, you can use 'postgresraster'
instead of 'postgres' as the providerType argument. That is:

iface.addRasterLayer(uri.uri(), 'my layer label', 'postgresraster')

You can find out these parameters (URI and provider type) with further
introspection: when you have loaded the layer manually, select it, open
a Python console, and you can get the layer Python object with:

>>> db_layer = iface.activeLayer()

Then you can get the source URI with:

>>> db_layer.source():

and the provider type with:

>>> db_layer.providerType()

With these parameters you can feed iface.addRasterLayer() method or
QgsRasterLayer() init method.

With QGIS 3.10 you can introspect this way too to find out the URI while
'gdal' is the provider.

Regards.

Yann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200501/a0f76719/attachment.html>


More information about the Qgis-user mailing list