Chapter 9. Reading and writing raster data
This chapter covers
- Understanding raster data basics
- Introducing GDAL
- Reading and writing raster data
- Resampling data
If you have a geographic dataset that’s made of continuous data such as elevation or temperature, it’s probably a raster dataset. Spectral data such as aerial photographs and satellite imagery are also stored this way. These types of datasets don’t assume strict boundaries exist between objects in the way that vector datasets do. Think of a digital photograph and how each pixel can be a slightly different color than the pixels next to it. The fact that pixel values can vary continuously like this makes for a much better-looking photo than if there were only a few colors to choose from. This trait also makes rasters appropriate for continuously varying data such as elevation.
Working with raster datasets is different from working with vectors. Instead of having individual geometries, you have a collection of pixels which is essentially a large two- or three-dimensional array of numbers. A raster dataset is made of bands instead of layers, and each of these bands is a two-dimensional array. The collection of bands becomes a 3D array. It’s a different way of thinking about spatial data, and if you have a math phobia, this description might make it sound scary, too. But you’ll soon see that it’s not.