Chapter 4. Using Raster Data

In this chapter, we will cover the following recipes:

  • Loading a raster layer
  • Getting the cell size of a raster layer
  • Obtaining the width and height of a raster
  • Counting raster bands
  • Swapping raster bands
  • Querying the value of a raster at a specified point
  • Reprojecting a raster
  • Creating an elevation hillshade
  • Creating vector contours from elevation data
  • Sampling a raster dataset using a regular grid
  • Adding elevation data to line using a digital elevation model
  • Creating a common extent for rasters
  • Resampling raster resolution
  • Counting the unique values in a raster
  • Mosaicing rasters
  • Converting a TIFF image to a JPEG image
  • Creating pyramids for a raster
  • Converting a pixel location to a map coordinate
  • Converting a map coordinate to a pixel location
  • Creating a KML image overlay for a raster
  • Classifying a raster
  • Converting a raster to a vector
  • Georeferencing a raster from ground control points
  • Clipping a raster using a shapefile

Introduction

This chapter shows you how to bring raster data into a GIS and create derivative raster products using QGIS and Python. QGIS is equally adept at working with raster data as with vector data, by incorporating leading-edge open source libraries and algorithms, including GDAL, SAGA, and the Orfeo Toolbox. QGIS provides a consistent interface to for large array of remote sensing tools. We will switch back and forth between visually working with raster data and using QGIS as a processing engine via the Processing Toolbox, to completely automating remote sensing workflows.

Raster data consists of rows and columns of cells or pixels, with each cell representing a single value. The easiest way to think of raster data is as images, which is how they are typically represented by software. However, raster datasets are not necessarily stored as images. They can also be ASCII text files or binary large objects (BLOBs) in databases.

Another difference between geospatial raster data and regular digital images is their resolution. Digital images express resolution as dots-per-inch, if they are printed in full size. Resolution can also be expressed as the total number of pixels in the image, defined as megapixels. However, geospatial raster data uses the ground distance that each cell represents. For example, a raster dataset with a two-feet resolution means that a single cell represents two feet on the ground. This also means that only objects larger than two feet can be identified visually in the dataset.

Raster datasets may contain multiple bands, meaning that different wavelengths of light can be collected at the same time over the same area. Often, this range is from 3 to 7 bands wide, but it can be several hundred bands wide in hyperspectral systems. These bands are viewed individually or swapped in and out as the RGB bands of an image. They can also be recombined using mathematics into a derived single band image and then recolored using a set number of classes, representing similar values within the dataset.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset