Data structures for rasters in the raster package
A raster is a rectangular grid of numeric values, referenced to a certain geographical extent. As previously mentioned, spatial referencing is what differentiates a raster from the simpler data structures (matrices and arrays) we have seen previously. A raster can have a single value in each cell (a single band, or single layer, raster—analogous to a matrix) or several values (a multiband, or multilayer, raster—analogous to an array). Rasters conceptually differ from vector layers, which are data structures to represent non-gridded objects such as spatial points, lines, and polygons (these will be covered in the next chapter).
In this book, we are going to work with classes to represent rasters from the raster
package. This package does not come with the R installation, so we first have to install it using install.packages
(see the previous chapter). We will also need to install the rgdal
package since functions in the raster...