More

Learning resources for PyQGIS?


I'm looking for some resources for learning PyQGIS.

It would be interesting having a collection of books or websites that provide some practical examples for learning the syntax or accomplishing specific tasks.

Ideally, these resources should give a general guidance for both beginner and experienced users.

Where to find QGIS tutorials and web resources? is a very similar question, but it gives help for learning QGIS, and not specifically PyQGIS (in fact, it doesn't have the PyQGIS tag).

Any help?


The following documentation resources should ease your PyQGIS development experience:

A diagram of the main PyQGIS relationships (by Thomas Gratier): https://raw.githubusercontent.com/webgeodatavore/qgis-class-diagram/master/diagramme_principal.png">http://geoapis.sourcepole.com

For example, theaddFeaturemethod you had problems with is described here: http://geoapis.sourcepole.com/qgispyapi/qgsvectorlayer#QgsVectorLayer.addFeature

As a second example, thesetAttributemethod is described here: http://geoapis.sourcepole.com/qgispyapi/qgsfeature#QgsFeature.setAttribute


The following resources give a general guidance for learning or using PyQGIS and generally assume a minimum proficiency of working with Python.


QGIS 3.x versions

  • PyQGIS 3 API Documentation: official documentation of the Python API. Documentation for each major release since v3.0 as well as the nightly version is provided;

  • PyQGIS Developer Cookbook: written for QGIS 2.x it is gradually updated to 3.x. It still may be helpful as a tutorial and a reference guide and gives a good overview of the principal functionalities.


QGIS 2.x versions

PyQGIS Documentation:

  • PyQGIS Developer Cookbook: official introduction to PyQGIS programming. It is intended to work both as a tutorial and a reference guide and gives a good overview of the principal functionalities;

  • PyQGIS API Documentation: inofficial documentation of the Python API by SourcePole. It provides a searchable interface, but was not updated since QGIS 2.8;

  • QGIS C++ API Documentation: official C++ API documentation. While describing the C++ API, it can be useful for pyqgis development.

Online books:

  • Sherman G. (2014). The PyQGIS Programmer's Guide: extending QGIS 2.x with Python;

  • Westra E. (2014). Building Mapping Applications with QGIS: for both beginners and experienced Python developers, this book covers a lot of topics about the using of PyQGIS, including the creation of QGIS plugins and the using of QGIS in an external application;

  • Lawhead J. (2015). QGIS Python Programming Cookbook: 140 recipes for learning and automating geospatial workflows;

  • Menke K., Richard S., Pirelli L. (2015). Mastering QGIS: some sections provide practical, step-by-step examples for familiarizing with PyQGIS;

  • Graser A. (2016). Learning QGIS - Third Edition: one section is entirely dedicated to scripting QGIS with Python, starting from the basis to a more advanced using of the several available tools;

  • Lawhead J. (2017). QGIS Python Programming Cookbook - Second Edition: this book has a complete code upgrade to QGIS 2.18 and 30 new recipes.

Tutorials / Blogs / Web resources:

  • Nathan Woodrow: a blog mostly about QGIS stuff that also treats specific topics about the using of PyQGIS. The author is one of the most active QGIS developers;

  • nyalldawson.net: a blog with several posts about the using of PyQGIS. The author is one of the most active QGIS developers;

  • "How To" in QGIS: the site provides some suggestions for solving problems using PyQGIS. When possible, these tips are offered through simple code samples. I'm the author of this blog;

  • QGIS Tutorials and Tips: a section of this blog provides a series of tutorials for learning PyQGIS scripting. The author is a very experienced GIS specialist;

  • Lutra Consulting: a list of posts, having the PyQGIS tag, that cover some topics about PyQGIS.


Not sure what you mean in Getting into Python API of QGIS?, but there is an addFeatures() function of course. This works in QGIS 2.4:

mem_layer = QgsVectorLayer("Polygon?crs=epsg:4326&field=MYNUM:integer&field=MYTXT:string", "temp_layer", "memory") if not mem_layer.isValid(): raise Exception("Failed to create memory layer") mem_layer_provider = mem_layer.dataProvider() my_polygon = QgsFeature() my_polygon.setGeometry(QgsGeometry.fromRect(QgsRectangle(16,48,17,49))) my_polygon.setAttributes([10,"hello world"]) mem_layer_provider.addFeatures([my_polygon]) mem_layer.updateExtents() QgsMapLayerRegistry.instance().addMapLayer(mem_layer)

If you are unhappy with the API docs and the PyQGIS Cookbook, your last chance is to look into working plugins - they are open source after all - and you can easily see if they work in 2.4…

To improve documentation, the project happily accepts resources of any kind.


Here are some urls that might help you:

  1. PyQGIS Developer Cookbook https://docs.qgis.org/3.10/en/docs/pyqgis_developer_cookbook/
  2. QGIS Python API documentation https://qgis.org/pyqgis/3.14/

Another collection for informations about learning PyQGIS:
http://spatialgalaxy.net/2014/10/18/pyqgis-resources/


Python and GIS Resources

Find resources to web sites about Python scripting to use in GIS. Learn how to use Python to expand your geographic information system. Esri uses Python as its scripting language for ArcGIS and the language can be found in many open source GIS applications. Also see: Learning Programming for GIS for general Python resources.

Python is a scripting language incorporated into many GIS software applications such as ArcGIS and QGIS and is used to automate geoprocessing tasks. Python scripts are essentially a command-based script containing data types, statements, and functions that make up the geoprocessing instructions. Python files are denoted with the .py file extension.


QGIS for Geographic Information System Training Course

A prior experience with Python and the libraries like pandas, matplotlib is highly recommended along with a knowldege around visualization tools and API usage.

A geographic information system (GIS) is a system designed to capture, store, manipulate, analyze, manage, and present spatial or geographic data. The acronym GIS is sometimes used for geographic information science (GIScience) to refer to the academic discipline that studies geographic information systems and is a large domain within the broader academic discipline of geoinformatics.

QGIS functions as geographic information system (GIS) software, allowing users to analyze and edit spatial information, in addition to composing and exporting graphical maps. QGIS supports both raster and vector layers vector data is stored as either point, line, or polygon features. Multiple formats of raster images are supported, and the software can georeference images. To summarize it allows the users to Create, edit, visualise, analyse and publish geospatial information on Windows, Mac, Linux, BSD.

This program, in its first phase, introduces the QGIS interface for general usage. In the second phase, we introduce PyQGIS - the python libraries of QGIS that allows the integration of GIS functionalities in your python code or your python application, so that you may even create your own Python Plugin around a particular GIS functionality.


Some of our clients

Is growing fast!

We are looking to expand our presence in Ireland!

As a Business Development Manager you will:

  • expand business in Ireland
  • recruit local talent (sales, agents, trainers, consultants)
  • recruit local trainers and consultants

We offer:

  • Artificial Intelligence and Big Data systems to support your local operation
  • high-tech automation
  • continuously upgraded course catalogue and content
  • good fun in international team

If you are interested in running a high-tech, high-quality training and consulting business.


QGIS Becoming a GIS Power User

  • Author : Anita Graser
  • Publisher : Packt Publishing Ltd
  • Release Date : 2017-02-28
  • Genre: Computers
  • Pages : 819
  • ISBN 10 : 9781788295574

Master data management, visualization, and spatial analysis techniques in QGIS and become a GIS power user About This Book Learn how to work with various types of data and create beautiful maps using this easy-to-follow guide Give a touch of professionalism to your maps, both for functionality and look and feel, with the help of this practical guide This progressive, hands-on guide builds on a geo-spatial data and adds more reactive maps using geometry tools. Who This Book Is For If you are a user, developer, or consultant and want to know how to use QGIS to achieve the results you are used to from other types of GIS, then this learning path is for you. You are expected to be comfortable with core GIS concepts. This Learning Path will make you an expert with QGIS by showing you how to develop more complex, layered map applications. It will launch you to the next level of GIS users. What You Will Learn Create your first map by styling both vector and raster layers from different data sources Use parameters such as precipitation, relative humidity, and temperature to predict the vulnerability of fields and crops to mildew Re-project vector and raster data and see how to convert between different style formats Use a mix of web services to provide a collaborative data system Use raster analysis and a model automation tool to model the physical conditions for hydrological analysis Get the most out of the cartographic tools to in QGIS to reveal the advanced tips and tricks of cartography In Detail The first module Learning QGIS, Third edition covers the installation and configuration of QGIS. You'll become a master in data creation and editing, and creating great maps. By the end of this module, you'll be able to extend QGIS with Python, getting in-depth with developing custom tools for the Processing Toolbox. The second module QGIS Blueprints gives you an overview of the application types and the technical aspects along with few examples from the digital humanities. Afte


Some of our clients

Is growing fast!

We are looking to expand our presence in Egypt!

As a Business Development Manager you will:

  • expand business in Egypt
  • recruit local talent (sales, agents, trainers, consultants)
  • recruit local trainers and consultants

We offer:

  • Artificial Intelligence and Big Data systems to support your local operation
  • high-tech automation
  • continuously upgraded course catalogue and content
  • good fun in international team

If you are interested in running a high-tech, high-quality training and consulting business.


Relationship between GDAL and GEOS and Learning Resources?

Hey everybody, I'm a software developer working on an application that has to perform geospatial queries (point in polygon, does provided polygon overlap 1..n polygons, etc). I have to support points, lines, ellipses and polygons. The application is written in C++. Googling around, I came across the Java Topology Suite (JTS) and then GEOS (C++ port) and GDAL. I'm trying to decide which one of these technologies to employ and in doing research I'm just a bit confused by the relationship between GDAL and GEOS. It seems GDAL wraps or encompasses GEOS (since there are build configuration options to compile GDAL with GEOS support presumably to realize the OGR Geometry functions). According to this page, it looks like GDAL provides non-linear geometry types whereas GEOS only supports linear. GEOS deals purely with Geometry but GDAL has more features and support for parsing popular data formats. Can anyone shed any more light on this for me? I've done a lot of searching to no avail.

Also, there really seems to be a lack of resources out there for learning these two libraries and how to use them. The learning curve seems a bit high. The APIs don't seem that intuitive to an uninitiated person like me. Anyone know of any good books or tutorials out there? I tried to do some searching but all I can find is python stuff. I'm thinking I'm going to have to read through python books/examples and then just translate them to C++.

What database are you using? Postgresql/PostGIS would be the first tool I would reach for if your application is web based. It has all of the spatial capabilites of GEOS/GDAL.

GEOS as you pointed out is a port of JTS. It deals with pure planar analysis. GDAL is primarily a Swiss army library for converting data between different formats, but it has much of the functionality of GEOS wrapped in. If you need to read/write shapefiles or any other form of geospatial data files, you will want GDAL.

The official GDAL documentation is detailed, but it takes some time to parse through it all. All the info you need is there.

Thanks for the reply! Yes! I have reviewed that example. My issue with their tutorials is that they mostly focusing on reading and writing from different formats (understandably). My main focus is really just the geometry package and the general associated concepts like projections and coordinate systems. So I was mainly looking for tutorials on the spatial topology/relationship (i.e. intersects, contains, covers, etc). My source of data is already determined and that part is not an issue for me (other than I'm still unclear on if I should convert the WGS84 radians that I receive into some other format).

I did some prototyping over the weekend and I created several different types of geometries (polygons, points, lines) in the general vicinity of Florida with the GEOS C++ API. I tested a bunch of the spatial relationship functions and that all looked great. I was just using the normal (-90,90),(-180,180) Lat,Lon for the coordinates. The issue I have is that if I try to create a polygon that crosses the international dateline (antimeridian), it wraps around the whole earth instead of taking the "short" route. Not sure how to fix this yet. I'm guessing the poles also have issues.

As I got halfway through reading your post I thought, man just use python! It seems like you came to the same conclusion, and sadly I don’t have any recommendations on C++ libraries for GIS.

Without any more details on what exactly your trying to do with your web app or the data your using, I can’t really give you a concrete answer. I can, however, give you a list of python libraries for GIS related stuff. It’s a little old, but most should be still maintained. Maybe you’ll find something useful below that will be easy to translate in C++ or works well with your data/tasks. Here’s to wishfully thinking.

GeoData Science Libraries

PySAL: PySAL is an open source library of spatial analysis functions written in Python intended to support the development of high level applications. PySAL is built upon the Python scientific stack including numpy and scipy.

Shapely: Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries. Shapely is not concerned with data formats or coordinate systems, but can be readily integrated with packages that are.

Fiona: Fiona is OGR’s neat, nimble, no-nonsense API for Python programmers. Fiona is designed to be simple and dependable. It focuses on reading and writing data in standard Python IO style and relies upon familiar Python types and protocols such as files, dictionaries, mappings, and iterators instead of classes specific to OGR. Fiona can read and write real-world data using multi-layered GIS formats and zipped virtual file systems and integrates readily with other Python GIS packages such as pyproj, Rtree, and Shapely. Fiona provides a minimal, uncomplicated Python interface to the open source GIS community’s most trusted geodata access library.

GeoPandas: GeoPandas is a project to add support for geographic data to pandas objects. The goal of GeoPandas is to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types. Geometric operations are performed by shapely. Geopandas further depends on fiona for file access and descartes and matplotlib for plotting.

GDAL/OGR: GDAL: Geospatial Data Abstraction Library. This Python package and extensions are a number of tools for programming and manipulating the GDAL_ Geospatial Data Abstraction Library. Actually, it is two libraries -- GDAL for manipulating geospatial raster data and OGR for manipulating geospatial vector data.

Cligj: Cligj is a small library which can be used to standardise processing of geoJSON in Python command line programs. cligj is for Python developers who create command line interfaces for geospatial data. cligj allows you to quickly build consistent, well-tested and interoperable CLIs for handling GeoJSON.

PyQGIS: PyQGIS is a blending of Python and Quantum GIS to extend and enhance your open source GIS toolbox. With PyQGIS you can write scripts and plugins to implement new features and perform automated tasks.

Pyshp: PyShp provides read and write support for the Esri Shapefile format. The Shapefile format is a popular Geographic Information System vector data format created by Esri.

Pyproj: pyproj is python interface to PROJ4 library for cartographic transformations. The Proj class can convert from geographic (longitude,latitude) to native map projection (x,y) coordinates and vice versa, or from one map projection coordinate system directly to another.

Rasterio: Rasterio employs GDAL to read and writes files using GeoTIFF and many other formats. Its API uses familiar Python and SciPy interfaces and idioms like context managers, iterators, and ndarrays. Fast and direct raster I/O for Python programmers who use Numpy. Rasterio is a GDAL and Numpy-based Python library designed to make your work with geospatial raster data more productive, more fun — more Zen. It’s a new open source project from the satellite team at Mapbox.

Cartopy: Cartopy is a cartographic python library with matplotlib support.

Geographiclib: For solving geodesic problems. Geodesic class to Python.

GeoDjango: GeoDjango is a Django application that is now included in the Django trunk with a lot of excellent stuff for developing GIS web application. GeoDjango installation is based on Python, Django and two kinds of components: a Spatial Database and Geospatial libraries.

Simplekml: The python package simplekml was created to generate kml (or kmz). It was designed to alleviate the burden of having to study KML in order to achieve anything worthwhile with it. If you have a simple understanding of the structure of KML, then simplekml is easy to run with and create usable KML.

Kartograph: Kartograph is a simple and lightweight framework for building interactive map applications without Google Maps or any other mapping service. It was created with the needs of designers and data journalists in mind.


ArcGIS Pro Python Reference

“The ArcGIS Pro Python Reference contains detailed information about every ArcPy module, function, and class provided with ArcGIS Pro, working with Python, as well as how to work with, and create your own, geoprocessing tools in Python.”

I frequently use this resource not just to check the syntax and parameter options for the various functions and classes but also because each provides one or more pieces of sample code for typical workflows that might involve it. You can think of this as being a somewhat static resource but, at each new release and often in between, more sample code is added, often in response to user requests.


Cursuri de pregatire QGIS for Geographic Information System

A prior experience with Python and the libraries like pandas, matplotlib is highly recommended along with a knowldege around visualization tools and API usage.

Un sistem de informații geografice ( GIS ) este un sistem conceput pentru a capta, stoca, manipula, analiza, gestiona și prezenta date spațiale sau geografice. Acronimul GIS este uneori folosit pentru știința informațiilor geografice ( GIS cience) pentru a face referire la disciplina academică care studiază sistemele de informații geografice și este un domeniu mare în cadrul disciplinei academice mai largi de geoinformatică.

Q GIS funcționează ca software pentru sistemul de informații geografice ( GIS ), permițând utilizatorilor să analizeze și să editeze informații spațiale, pe lângă compunerea și exportarea hărților grafice. Q GIS acceptă atât straturi raster, cât și vectoriale datele vectorului sunt stocate fie ca caracteristici punct, linie sau poligon. Mai multe formate de imagini raster sunt acceptate, iar software-ul poate georeferența imagini. Pentru a rezuma, permite utilizatorilor să creeze, să editeze, să vizualizeze, să analizeze și să publice informații geospatiale pe Windows, Mac, Linux , BSD.

Acest program, în prima sa fază, introduce interfața Q GIS pentru utilizare generală. În a doua fază, introducem PyQ GIS - bibliotecile python ale Q GIS care permite integrarea funcționalităților GIS în codul dvs. python sau în aplicația dvs. python, astfel încât puteți chiar să vă creați propriul dvs. Python Plugin în jurul unei anumite funcționalități GIS .


Tips for creating good routes

Use the software to properly track yourself on the trail using the GPS tracking.

Start at the trailhead for the trail you are gathering data for and turn on the tracking software. Depending on which app or device you choose there may be specific instructions you need to follow. Make sure to read up on any help or instructional sections that may be relevant. Keep in mind that for an accurate route you’ll want to minimize detours and backtracking to save time editing the route when making your map. By tracking from the trailhead to the end of the trail (whether that be linear or a loop) and avoiding detours you should be gathering data that can create an accurate map, although all routes will need some editing. You will save this data to be plugged into GIS reading software, such as the freely available QGIS. If you are a volunteer gathering this data for an organization, the saved file is what you will send to the organization, who will then plug it into their own GIS reading software.


Watch the video: PyQGIS print field names (October 2021).