1

I want to get QGIS to update from a CSV file like in this How to update data from external table in real time? question, however I can't figure out what to put for "myLayer". How can I define the active QGIS layer in my code?

swooders
  • 83
  • 4

1 Answers1

1

The most basic approach would be

myLayer = iface.activeLayer()
underdark
  • 84,148
  • 21
  • 231
  • 413
  • Thank you for the response! However I did try that and I got 'name "iface" is undefined' so it doesn't compile - do you know why? – swooders Feb 16 '15 at 21:55
  • Which QGIS version are you using? The code provided by @underdark should work (I use QGIS 2.2 and 2.6 and worked for both). To be extra safe, you could first try import qgis.utils and then myLayer = qgis.utils.iface.activeLayer() – Joseph Feb 17 '15 at 10:39
  • I'm using 2.6 and import qgis.utils worked! Thank you so much. – swooders Feb 17 '15 at 16:35