I am trying to use the 'grainchanger' package in R to aggregate finer resolution raster to a coarser one.
I have 10km grid outlines of the UK, which I have converted from shapefile to raster.
I also have a land cover map of the UK in raster form.
I need to look at the land cover %s in each 10km square of the land cover map.
When I try aggregating this using the grainchanger package, I get the following error:
Error in .local(x, y, ...) : extents do not overlap
I think this is because my 10km grid raster is squares which the land cover map does not fill.
How can I change the extent of the land cover map so it matches the 10km grid raster?
This is my code:
library(raster)
# continuous landscape
show_landscape(cont_ls)
# load the coarse resolution raster
g_raster <- raster("raster.tif", package = "grainchanger")
show_landscape(g_raster)
# direct aggregation using range
dda <- nomove_agg(coarse_dat = g_raster,
fine_dat = cont_ls,
agg_fun = var_range)
#> aggregation assumes all cells are rectangular
#> ● set `is_grid = FALSE` if coarse_dat is not a grid