I want to create a plugin which can draw irregular polygons in QGIS. For that, I want to call the Select features by freehand default tool inside my plugin. How can I do this within a python script?
Asked
Active
Viewed 767 times
1
-
You want to call all its functionality (i.e., draw a polygon and select features) or only to draw the polygon? – Germán Carrillo Feb 19 '15 at 13:02
-
I want to draw a irregular polygon select all it's data from table and write it as a csv file. – Shiva Feb 19 '15 at 13:08
1 Answers
2
This should work:
iface.actionSelectFreehand().trigger()
Germán Carrillo
- 36,307
- 5
- 123
- 178
-
I'm new to qgis so where i want to add this code exactly inside my .py file – Shiva Feb 19 '15 at 13:28
-
Difficult from me to say. It depends on your plugin's logic. Please see What is the purpose of some functions and files in QGIS Python plugins? to figure it out. Most of the cases you would like to put the code in the
run( self )method. You need to make sure you have stored a reference to theifaceobject inside the__init__( self, iface )function. – Germán Carrillo Feb 19 '15 at 13:43 -
Note that you could run the line of code from my answer directly in the QGIS Python console, but in your plugin you would call it this
self.iface.actionSelectFreehand().trigger(). – Germán Carrillo Feb 19 '15 at 13:44 -