Session Ready
Exercise

Reading raster data

The term "raster" refers to gridded data that can include satellite imagery, aerial photographs (like orthophotos) and other types. In R, raster data can be handled using the raster package created by Robert J. Hijmans.

When working with raster data, one of the most important things to keep in mind is that the raw data can be what is known as "single-band" or "multi-band" and these are handled a little differently in R. Single-band rasters are the simplest, these have a single layer of raster values -- a classic example would be an elevation raster where each cell value represents the elevation at that location.

Multi-band rasters will have more than one layer. An example is a color aerial photo in which there would be one band each representing red, green or blue light.

Instructions
100 XP
  • Load the raster package.
  • Read in the tree canopy raster with the raster() function (this is a single-band raster called "canopy.tif").
  • Read in the Manhattan Landsat image with brick() (this is a multi-band raster called "manhattan.tif").
  • Use the class() function to determine the class of each raster object you read in.
  • Use the nlayers() function to determine how many bands/layers are in each object.