HES 505 Fall 2023: Session 14
By the end of today, you should be able to:
Use moving windows as a means of smoothing raster data
Reclassify data using conditional statements and reclassification tables
Use raster math as a means of creating new data based on an existing dataset.
To create new data that reflects “neighborhood” data
To smooth out values
To detect (and fill) holes or edges
Change the thematic scale of your data (without changing resolution)
R
focal
function in terra
focal(x, w=3, fun="sum", ..., na.policy="all", fillvalue=NA, expand=FALSE, silent=TRUE, filename="", overwrite=FALSE, wopt=list())
focal
for Continuous Rastersfocal
for Continuous Rastersfocal
for Continuous Rastersfocal
for Continuous Rastersfocal
for Continous Rasterscan alter the size and shape of window by providing a weights matrix for w
Can create different custom functions for fun
(see the help file)
na.policy
for filling holes or avoiding them
Create new data based on the presence of a particular class(es) of interest
Combine classes in a categorical map
Useful as inputs for overlay analyses
R
[]
and conditionalsR
[]
and conditionalsclassify
SpatRasters
terra
has a special set of apply
functions
app
, lapp
, tapp
app
applies a function to the values of each cell
lapp
applies a function using the layer as the value
tapp
applies the function to a subset of layers
distance
and relatives are based on relationships between cells
terrain
allows calculation of slope, ruggedness, aspect using elevation rasters
shade
calculates hillshade based on terrain