[Qgis-user] Click to open layer

Richard McDonnell richard.mcdonnell at opw.ie
Fri May 19 08:41:53 PDT 2023


Hi Grant,
Do you mean insert a GeoTIFF in?
If that's the case, then you want the following Action..

Type: Python
Description: Add Raster to Canvas or whatever you want
Action Text: qgis.utils.iface.addRasterLayer('[%filepath%][%filename%]','[%filename%]')

For the above to work, you will need two attributes in your Polygon, a "filepath" and a "filename" attribute. In the fileparh is the Path to the folder containing the GeoTiff and the filename is the name of the file you are looking to load... so something like this...

[cid:image001.png at 01D98A70.D05A4F50]

This should then load any GeoTIFF into your Canvas.
Kind Regards,

Richard


--
Richard McDonnell MSc GIS, FME Certified Professional
FRM Data Management

--
Oifig na nOibreacha Poibl?
Office of Public Works

Sr?id Jonathan Swift, Baile ?tha Troim, Co na M?, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
--
M +353 87 688 5964 T +353 46 942 2409
https://gov.ie/opw

--
To send me files larger than 30MB, please use the link below https://filetransfer.opw.ie/filedrop/richard.mcdonnell@opw.ie

Email Disclaimer: https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/

--
MSc GIS, FME Certified Professional

--
Oifig na nOibreacha Poibl?
Office of Public Works

Sr?id Jonathan Swift, Baile ?tha Troim, Co na M?, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
--
M +353 87 688 5964 T +353 46 942 2409
https://https://gov.ie/opw<https://www.opw.ie>

--
Email Disclaimer: https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/<https://www.opw.ie/en/disclaimer/>
From: QGIS-User <qgis-user-bounces at lists.osgeo.org> On Behalf Of Grant Boxer via QGIS-User
Sent: 19 May 2023 09:47
To: qgis-user at lists.osgeo.org
Subject: [Qgis-user] Click to open layer

I am sure there is a simple way to do this but I would like to click on a polygon and get it to open a tiff file into my map canvas. Do I use an Action and an "open" command?
Regards Grant Boxer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230519/d104ded3/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3128 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230519/d104ded3/attachment.png>


More information about the QGIS-User mailing list