HES 505 Fall 2024: Session 13
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
You are tasked with the following (admittedly silly) analysis by the “Wildfire for Insurance Agents” group. They would like a map of wildfire risk in Idaho with these categories: “No worries,” “A little bit risky,” “Moderate risk,” and “Very risky,” and “Don’t move here.” They don’t want any stakeholders to feel that their properties stand out unfairly, so they don’t want pixels that are different from the pixels around them. Choose a county to present this analysis to and make a map for that audience as well as the state map.
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.