4

I thought I would try to write a plugin for QGIS (some Python code that I hoped I could easily port) I started following http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html but that turned out to be hopelessly out of date. I turned to http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html instead and started going through the intro for the Python console and stumbled at the second query.

layer = qgis.utils.iface.activeLayer()

worked fine but then

layer.getLayerID()

threw up

Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'QgsVectorLayer' object has no attribute 'getLayerID'

and sure enough code completion in the console would seem to suggest that this doesn't exist. So my question is "where do I find up to date, usable instructions for developing plugins for QGIS 2.2?" It would seem that unless you are already "in the know" there is no way in. Or am I just being paranoid?

5

The most complete API docs are located at http://qgis.org/api/classQgsMapLayer.html

A good Python-specific resource is The PyQGIS Programmer's Guide. It's new and written for the 2.x API.

Concerning the pyQGIS Cookbook: I assume you are referring to the screenshot on http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html? This seems to have slipped through when the documentation was updated. That can happen. If you find documentation issues, it would be extremely helpful if you report them on the QGIS Documentation Github page.

  • Any idea when the newbie intro will be updated? Ploughing through the API each time the old intro bowls a googly doesn't appeal at the moment (in the middle of writing PhD thesis and need less, not more stress). – mercergeoinfo Mar 9 '14 at 1:57
  • 1
    Try locatepress.com/ppg – gsherman Mar 9 '14 at 4:36
  • All documentation resources are continually updated - mostly by volunteers. You can support their efforts by letting them know if you spot certain issues. – underdark Mar 9 '14 at 10:06
2

To complete the Underdark's list I like those :

  • Joel Lawhead, 2015. Qgis python programming cookbook. Packt Publishing, p 340.
  • Erik Westra, 2014. Building Mapping Applications with QGIS. Packt Publishing, p 150.
  • Anita Graser, 2014. Learning Qgis. Packt Publishing, p 150. ;)

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.