Gary Sherman's PyQGIS Programmer's Guide: Extending QGIS 3 with Python 3
is a foundational resource for developers transitioning from QGIS 2 to the modern QGIS 3 ecosystem. This 252-page guide is available as a PDF from Locate Press
and focuses on bridging the gap between basic Python scripting and professional QGIS plugin development. New York University Core Pillars of the Guide
The book is structured to lead a reader from local environment setup to deploying standalone GIS applications: Environment & Setup
: It provides platform-specific instructions for Windows, macOS, and Linux to configure Python 3 paths and dependencies, ensuring scripts correctly access the QGIS libraries. The QGIS API
: A deep dive into the Application Programmer Interface (API), teaching you how to navigate the framework of classes (most starting with the prefix) and their functions. Layer Management & Geoprocessing Vector & Raster Operations pyqgis programmer 39s guide 3 pdf work
: Detailed workflows for loading layers, querying attributes, and modifying spatial data.
: Using the rendering engine to programmatically change layer appearance (e.g., using QgsSingleSymbolRenderer Plugin Development
: A comprehensive section on building, testing, and debugging custom plugins to extend QGIS functionality. Ecosystem Integration
: Instructions on combining PyQGIS with data science libraries like Matplotlib for advanced statistical analysis and charting. New York University Key Updates for QGIS 3.x
Unlike earlier versions, this edition specifically addresses the major shifts in the developer landscape: Python 3 Compatibility : Full migration guide from Python 2 to Python 3. Porting Code Gary Sherman's PyQGIS Programmer's Guide: Extending QGIS 3
: Dedicated content on converting legacy scripts to be compatible with the QGIS 3.0 API. Processing Framework
: Emphasis on leveraging the Processing toolbox to run algorithms from GDAL, GRASS, and SAGA programmatically. New York University Access and Supplemental Resources : You can buy the full PDF or print copy at Locate Press or through retailers like Code Samples
: The accompanying code for the book's exercises can be downloaded as a ZIP file from Locate Press Alternative Guides : For a shorter, free reference, the QGIS Developer Cookbook is the official documentation maintained by the community. Locate Press Pyqgis Programmers Guide Gary Sherman - CLaME
The PyQGIS Programmer's Guide and similar resources are designed to help you navigate the powerful features of QGIS and automate and extend your workflow. Enjoy exploring the possibilities of PyQGIS!
Launch the Python Console in QGIS: QGIS comes with an integrated Python console which you can use to test PyQGIS commands immediately. You can find it under Plugins > Python Console. PyQGIS Documentation : Make sure to check the
Reference the PyQGIS API: The PyQGIS API documentation and the PyQGIS Programmer's Guide are invaluable resources. The guide provides explanations and examples that help you understand how to interact with QGIS using Python.
Example Script: Start with a simple script. For example, to create a new QGIS project:
import qgis
from qgis.core import QgsApplication, QgsProject
# Initialize QGIS
QgsApplication.setPrefixPath("/path/to/qgis/installation", True)
QgsApplication.initQgis()
# Create a new project
project = QgsProject.instance()
print("Project title:", project.title())
# Clean up
QgsApplication.exitQgis()
However, note that this kind of initialization and cleanup is usually more relevant in standalone applications. When running scripts from within QGIS (e.g., via the Python console), it often isn't necessary.
| Resource | QGIS Version | Official PDF? | Works? | |----------|--------------|---------------|---------| | Gary Sherman's PyQGIS Programmer's Guide | 2.x | Yes (paid) | No for QGIS 3 | | Official QGIS PyQGIS Developer Cookbook | 3.x | No (HTML only) | Yes (online) | | Community-made PDF from cookbook | 3.x | Unofficial | Possibly, but risky |