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?
-
You want to call all its functionality (i.e., draw a polygon and select features) or only to draw the polygon?– Germán CarrilloCommented Feb 19, 2015 at 13:02
-
I want to draw a irregular polygon select all it's data from table and write it as a csv file.– ShivaCommented Feb 19, 2015 at 13:08
Add a comment
|
1 Answer
This should work:
iface.actionSelectFreehand().trigger()
-
I'm new to qgis so where i want to add this code exactly inside my .py file– ShivaCommented Feb 19, 2015 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 theiface
object inside the__init__( self, iface )
function. Commented Feb 19, 2015 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()
. Commented Feb 19, 2015 at 13:44 -