Book Image

QGIS Python Programming Cookbook

Book Image

QGIS Python Programming Cookbook

Overview of this book

Table of Contents (16 chapters)
QGIS Python Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating pyramids for a raster


Pyramids, or overview images, sacrifice the disk space for map rendering speed by storing resampled, lower-resolution versions of images in the file alongside the full resolution image. Once you have finalized a raster, building pyramid overviews is a good idea.

Getting ready

For this recipe, we will use a false-color image, that you can download from https://geospatialpython.googlecode.com/files/FalseColor.zip.

Unzip this TIF file and place it in your /qgis_data/rasters directory.

How to do it...

The Processing Toolbox has a dedicated algorithm for building pyramid images. Perform the following steps to create pyramids for a raster

  1. Start QGIS.

  2. From the Plugins menu, select Python Console.

  3. Import the processing module:

    import processing
    
  4. Run the gdalogr:overviews algorithm, specifying the process name, input image, overview levels, the option to remove existing overviews, resampling method (0 is the nearest neighbor), and overview format (1 is internal):

    processing.runalg...