1

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 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
2

This should work:

iface.actionSelectFreehand().trigger()
  • 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 the iface object 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
  • @gccarrillo Sorry i dont knw about that. – Shiva Mar 3 '15 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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