PyQGIS: Calculate Geometry and Field Values with the QGIS Python API
|

PyQGIS: Calculate Geometry and Field Values with the QGIS Python API

Using attribute fields in calculations is one of the most fundamental components of GIS analysis. Field calculations are what makes it possible to take data linked to spatial features and analyze features based on what they are and where they are. Manually performing field calculations in QGIS can be tedious, especially if you’re working with…

PyQGIS: Dissolve Vector Features with Python and QGIS
|

PyQGIS: Dissolve Vector Features with Python and QGIS

The QGIS Python API (PyQGIS) makes it really simple automate a feature dissolve. PyQGIS gives access to all the QGIS processing tools directly from the Python interface. This tutorial will demonstrate three different dissolve examples with Python in QGIS. Basic Dissolve with Python First, lets dissolve polygon features into a single polygon, this is the…

Zonal Statistics Algorithm with Python in 4 Steps
| | |

Zonal Statistics Algorithm with Python in 4 Steps

It is a common need to summarize information from a gridded dataset within an irregularly shaped area. While at first glance this may seem simple, reconciling differences between raster (gridded) and vector (polygon) datatypes can quickly become complicated. This article shows how to implement a zonal statistics algorithm in Python in 4 steps. Load raster…

|

PyQGIS: Shapefile from Selected Features

A common operation with vector layers is to select features based on attribute values and save those features to a new vector layer (i.e. shapefile). This tutorial will walk you through how to create a new shapefile from selected features. We’ll select some features, then save those features to a new shapefile. First, we’ll open…

|

PyQGIS: Create Raster

In a previous tutorial I showed you how to access raster values and data with the Geospatial Data Abstraction Library (GDAL). This tutorial will show you how to create a raster with GDAL. Start by importing the gdal and osr Python modules. The osr module is used for handling spatial references. Also import numpy. Now…

|

PyQGIS: Loading and symbolizing raster layers

More information can be found in the PyQGIS Developer Cookbook. Requirements QGIS version 3.0, or greater Objectives Load and symbolize a raster layer with pyqgis Get statistics from a raster band Open the QGIS Python Console From the menu, select Plugins -> Python Console, or Ctrl + Alt + P (Windows) You can type directly into…