Book Image

Learning R for Geospatial Analysis

By : Michael Dorman
Book Image

Learning R for Geospatial Analysis

By: Michael Dorman

Overview of this book

Table of Contents (18 chapters)
Learning R for Geospatial Analysis
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
External Datasets Used in Examples
Cited References
Index

Subsetting rasters


In many situations, we would like to access the values of a given raster either to perform calculations involving these values (for example, to calculate a frequency table) or to make an assignment (for example, to change a certain value in the raster; see the previous code section in Chapter 1, The R Environment). In this section, we are going to cover the different ways to do this.

As an example, we are going to use another multiband raster, modis.tif. First, we will assign it to a RasterBrick object named r and print its properties, as follows:

> r = brick("C:\\Data\\modis.tif")
> r
class       : RasterBrick
dimensions  : 100, 100, 10000, 280  (nrow, ncol, ncell, nlayers)
resolution  : 500, 500  (x, y)
extent      : 660000, 710000, 3445000, 3495000  (xmin, xmax, ymin$
coord. ref. : +proj=utm +zone=36 +datum=WGS84 +units=m +no_defs +$
data source : C:\Data\modis.tif
names       : modis.1, modis.2, modis.3, modis.4, modis.5, modis.$

The modis.tif file contains Normalized...