Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

1 Answer 1

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 action.name() == 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

 
discard

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.