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

Mosaicing rasters


Mosaicing rasters is the process of fusing multiple geospatial images with the same resolution and map projection into one raster. In this recipe, we'll combine two overlapping satellite images into a single dataset.

Getting ready

You will need to download the overlapping dataset from https://geospatialpython.googlecode.com/svn/overlap.zip if you haven't downloaded it from a previous recipe.

Place the two images in your /qgis_data/rasters/ directory.

How to do it...

This process is relatively straightforward and has a dedicated algorithm within the Processing Toolbox. Perform the following steps:

  1. Start QGIS.

  2. From the Plugins menu, select Python Console.

  3. Run the gdalogr:merge algorithm, specifying the process name, two images, a boolean to use the pseudocolor palette from the first image, a boolean to stack each image into a separate band, and the output filename:

    processing.runalg("gdalogr:merge","C:/qgis_data/rasters/Image2.tif;C:/qgis_data/rasters/Image1.tif",False,False,"/qgis_data...