1

I want to enable single feature selection using Python. I want to make a script in Python that will first enable single feature selection, and then it will return the id of selected feature. I have coded the second part, but how do I enable single feature selection?

layer = iface.activeLayer()
h = layer.selectedFeatures()
 for f in h:
 g = f['ID']
 print g
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Apr 15, 2017 at 9:19
1
  • What do you mean by single feature selection? Commented Apr 16, 2017 at 18:34

1 Answer 1

2

What do you mean by single feature selection? The Select Feature(s) tool is single feature select if you just click and do not drag the cursor.

You can set the active tool with:

iface.actionSelect().trigger()

You can write your own selection tool like described here:

Creating Selection MapTool in PyQgis Custom Application

answered Apr 16, 2017 at 11:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.