O'Reilly logo

QGIS Python Programming Cookbook by Joel Lawhead

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sampling a raster dataset using a regular grid

Sometimes, you need to sample a raster dataset at regular intervals in order to provide summary statistics or for quality assurance purposes on the raster data. A common way to accomplish this regular sampling is to create a point grid over the dataset, query the grid at each point, and assign the results as attributes to those points. In this recipe, we will perform this type of sampling over a satellite image. QGIS has a tool to perform this operation called regular points, which is in the Vector menu under Research Tools. However, there is no tool in the QGIS API to perform this operation programmatically. However, we can implement this algorithm directly using Python's numpy module.

Getting ready ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required