I have a list of a spatial dataset and a stack of rasters. The sf represent fires from 1985 to 2017 and the stack of rasters represent the climate conditions from 1985 to 2017. I want to extract the raster values for each pixel in the fire polygons using the exact_extract function in R. The function has the argument include_cols which is an optional character vector of column names in sf to be added to the data frame. Also, it has the argument append_cols that do the same when the fun is not NULL. However, when I try to apply the function I get the following error:
Error in `[.data.frame`(x, i, j, drop = drop) :
undefined columns selected
Here is my code:
waterclimPre_extract<- mapply(x= waterclimPre_maps, y = polys_maps, FUN= function(x,y)
exact_extract(x, y, include_xy = T, include_cell=T, include_cols = c("year", "fireClas")))
and also:
waterclimPre_stat <- mapply(x= waterclimPre_maps, y = polys_maps, FUN= function(x,y)
exact_extract(x, y, fun = c("mean", "min", "max", "median", "variance"), append_cols = c("year", "fireClas")))
mapply
out of the equation and show the problem with just a call toexact_extract
? Can you show which packages you used?