3

I am looking to add to my current action in QGIS so that a hyperlinked file will open in the current QGIS window, rather than in a new window. Here is what my action looks like:

"C:/Program Files (x86)/Quantum GIS Wroclaw/apps/qgis/bin/qgis.exe" "C:\Users\Ryan Garnett\Dropbox\SpatialData\Imagery\Landsat\%Image"

I am hoping I can use this as a means to share data so that users can load in satellite images basked on a click with the Hotlinks plugin.


Thanks Nathan, I tried this, but it did not load the file. It came back with the following error:

C:\Users\Ryan Garnett\Dropbox\SpatialData\Imagery\Landsat8020_nad83_utm_30m_123457.jp2 is not a valid or recognized raster data source

This is what I have written in the action:

qgis.utils.iface.addRasterLayer("C:\Users\Ryan Garnett\Dropbox\SpatialData\Imagery\Landsat\%Image")

With is set to Python. I have noticed in the error that there isn't a \ in between Landsat and the file name, plus the file name has been cut short, from 028020_nad83... to Landsat8020_nad83...

Any thoughts? My other way is still working.

4

You can open a layer in the current instance with a bit of python code in the layer action.

qgis.utils.iface.addRasterLayer("C:\Users\Ryan Garnett\Dropbox\SpatialData\Imagery\Landsat\%Image")

Switch the action type to Python .

Reference for interface object http://qgis.org/api/classQgisInterface.html

  • I figured it out. You needed to change all the \ to \\ for Python. qgis.utils.iface.addRasterLayer("C:\\Users\\Ryan Garnett\\Dropbox\\SpatialData\\Imagery\\Landsat\\%Image") – Ryan Garnett Apr 23 '12 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.