Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to create a map in QGIS 1.8 with indexed titles which are connected with topo-map titles files (geoTIFFs). My endeavor is to make (if it is possible) layer which can react on user mouse click (all of them will use the same PC and the same account) and then reveal/show/load desired map title.

Example: In this screenshot is a selection of titles in layer which I would like to load. All titles are made with "Title index" feature in Raster->Misc and contain path to source geoTIFF file.

enter image description here

My very first guess was to try various action in layer properties (in my case in Index layer). Even if I add default action, none of them seems to be the right one for me (maybe only seems) and I didn't find any similar plugin in repositories.

share|improve this question
up vote 3 down vote accepted

This can be done with a layer action using python:

Something like:

qgis.utils.iface.addRasterLayer('[% location %]')

where [% location %] will get replaced with the value of the field location at run time.

Running actions for each selected object:

layer = iface.activeLayer()
actionrunnner = layer.actions()
features = layer.selectedFeatures()

def getActionByName(name):
    """ Return the index of the action with name """
    for i in range(actionrunnner.size()):
        action = actionrunnner[i]
        if == name:
            return i

indx = getActionByName("MyAction")

if indx:
    for feature in features:
        actionrunnner.doActionFeature(indx, feature)

add the above to a file and you can then run it using excefile(path to file)

The above code will find an action with the name "MyAction" and run it for each selected feature in the current layer.

share|improve this answer
Thanks for help, that works! Only for one title/square instead whole selection but still enough :] – San-Tus Nov 20 '12 at 3:53
You could write a little bit of Python to fire the action for each feature. Code coming soon. – Nathan W Nov 20 '12 at 4:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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