Description Usage Arguments Value Examples
View source: R/calc_functions.R
Calculate the proportion of a given value present within a raster. Useful for calculating land-cover or soil type proportions. Should be used with a categorical raster
1 2 3 4 5 6 7 |
x |
numeric, winmove. The data over which to calculate the proportion |
lc_class |
numeric. The class value to calculate the proportion of |
... |
further arguments passed to or from other methods |
d |
numeric. If |
type |
character. The shape of the moving window |
If class(x) == "winmove"
, a smoothed raster with the proportion of
cells of the given class calculated within the specified moving window
If class(x) == "numeric"
, a single value representing the proportion of values
of a given class in x
1 2 3 4 5 6 7 8 9 10 11 12 | # load required data
data(cat_ls)
# convert data to object of class winmove
cat_ls <- new("winmove", cat_ls)
# aggregate using a rectangular window with dimension 5 for class 3
d <- prop(cat_ls, d = 5, type = "rectangle", lc_class = 3)
# convert data to object of class numeric
cat_ls <- raster::values(cat_ls)
d <- prop(cat_ls, lc_class = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.