[Qgis-user] qgis python script, add raster to bottom of map

Johannes Kröger (WhereGroup) johannes.kroeger at wheregroup.com
Tue Nov 2 00:27:30 PDT 2021


Hi Tim,

there are multiple options:

You can consult the QGIS PyQGIS cookbook for an example: 
https://docs.qgis.org/3.16/en/docs/pyqgis_developer_cookbook/loadlayer.html#qgsproject-instance

Or when you google for "pyqgis add layer" plus "order", "bottom" or 
"specific index", those terms should get you going with various examples 
at gis.stackexchange.com. Those are for a number of different use cases 
so best look around yourself what best suits you.

Cheers, Hannes

Am 02.11.21 um 06:20 schrieb tim dunlevie:
> Hi all,
>
> I have an index of rasters.
> I have added an action to the QGIS dataset which will open the raster 
> directly into QGIS.
>
> The script I use is this:
>
> from qgis.utils import iface
> qgis.utils.iface.addRasterLayer('[% path %]')
> index = 
> QgsProject.instance().mapLayersByName('Catalogue_Raster_Aerial_Photography')[0]
> iface.setActiveLayer(index)
>
> It works well, except the raster loads to the 'top' of the layer list.
> Is there a command to use so that the image loads to the bottom of the 
> map?
> I prefer to have my index always on top of the list.
>
> thanks
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

-- 
Johannes Kröger / GIS-Entwickler/-Berater
WhereGroup GmbH
Eifelstraße 7
53119 Bonn
Germany

Tel: +49 (0)228 / 90 90 38 - 36
Fax: +49 (0)228 / 90 90 38 - 11

johannes.kroeger at wheregroup.com
www.wheregroup.com
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
-------------------------------

---------------------------------------------
Schon gewusst?
In unserem Blog geben wir Tipps & Tricks zu
Open-Source-GIS-Software und berichten aus unserem Experten-Alltag:
https://wheregroup.com/blog/
---------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211102/09890ba9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xBF7B268A77C202D5.asc
Type: application/pgp-keys
Size: 2471 bytes
Desc: OpenPGP public key
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211102/09890ba9/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 665 bytes
Desc: OpenPGP digital signature
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211102/09890ba9/attachment.sig>


More information about the Qgis-user mailing list