[Qgis-user] Click to open layer

Richard McDonnell richard.mcdonnell at opw.ie
Mon May 22 02:59:20 PDT 2023


Hi Grant,
My advice would be to have a shared drive, or network drive, which both machines access with the same path.
But...in the absence of that, you could also modify your path if you prefer...
The Filepath attribute could be shortened/modified, and you can manually set the start of the path. So for example..

You can set your "filepath" attribute to something like..  someRootfolder/somesubfolders/ and your action text would be


1.       MACHINE1          qgis.utils.iface.addRasterLayer('C:/somefilepath/[%filepath%][%filename%]','[%filename%]')

2.       MACHINE2          qgis.utils.iface.addRasterLayer('E:/someOTHERfilepath/[%filepath%][%filename%]','[%filename%]')

As long as the attributes stay the same, as in the same Root and Subfolders, then the first path can be anything...
So for arguments sake...


1.       MACHINE1          qgis.utils.iface.addRasterLayer('D:/00_DATA_VALIDATION/[%filepath%][%filename%]','[%filename%]')

2.       MACHINE2                 qgis.utils.iface.addRasterLayer('//some_network_host/localdrive/00_DATA_VALIDATION/[%filepath%][%filename%]','[%filename%]')

I hope that's helps.
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: boxerg at iinet.net.au <boxerg at iinet.net.au>
Sent: 20 May 2023 00:29
To: Richard McDonnell <richard.mcdonnell at opw.ie>
Subject: RE: [Qgis-user] Click to open layer

Hi Richard,

Thanks for that. Can I use a project path that points to the project folder, something like  '.\' ? I use two different machines and so it would be good to be able to use the local address.

Cheers Grant


From: Richard McDonnell <richard.mcdonnell at opw.ie<mailto:richard.mcdonnell at opw.ie>>
Sent: Friday, May 19, 2023 11:42 PM
To: boxerg at iinet.net.au<mailto:boxerg at iinet.net.au>
Cc: qgis-user at lists.osgeo.org<mailto:qgis-user at lists.osgeo.org>
Subject: RE: [Qgis-user] Click to open layer

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 01D98C99.DC1C7E00]

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<mailto: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<mailto: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/20230522/eb25026e/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/20230522/eb25026e/attachment.png>


More information about the QGIS-User mailing list