So I'm working on a project where I have to check the classification of a bunch of points in a QGIS project. I have created a styling which means I can perform this task with visual inspection. I have a field simply called 'check' with default value of 'no', which I then change to 'yes' when I have checked a point.

Is there any way to create an action so that I can simply click on a point and auto-change its value to yes without having to open my attribute table every time?

1 Answer 1


You can use a simple Python action to do just that. Open the layer properties dialog for your point layer and click on the 'Actions' tab. Click on the green cross to add a new action and configure the action as shown in my screenshot below (you can use whatever name and description you like for your action- this is just an example):

enter image description here

Paste the code snippet below into the editor, making sure the field name string matches yours (I take it your field is called 'check') and click 'OK'.

from qgis.utils import iface

layer_id = '[%@layer_id%]'
layer_obj = QgsProject().instance().mapLayer(layer_id)
fid = [%$id%]
fld = layer_obj.fields().lookupField('check')
with edit(layer_obj):
    layer_obj.changeAttributeValue(fid, fld, 'Yes')

Now, when your point layer is active, you will notice that the 'Actions' tool icon is enabled.

enter image description here

You can click on it to activate the action you just created. You will see that the map tool cursor is now a cross, and when you click on a feature, its attribute value in the 'check' field will be updated to 'Yes'. By the way, if you have overlapping points, you will get a small dialog with a list of the 'stacked' feature ids, and you can select the one you want to update (or update them all). Once you are finished, simply select a different map tool to deactivate the action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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