Calculate local densities of subpopulations (race-specific local densities)
create_densities(x, y, window_size)
SpatRaster with realizations
SpatRaster with shares of subpopulations
Size, expressed in the number of cells, of a square-shaped local window for which local densities will be calculated; it is recommended to use the small window_size, i.e., 10
a SpatRaster containing n local densities. Local density layer is calculated for each realization
library(terra)
race_raster = rast(system.file("extdata/race_raster.tif", package = "raceland"))
real_rasters = create_realizations(race_raster, n = 5)
plot(real_rasters)
dens_raster = create_densities(real_rasters, race_raster, window_size = 10)
dens_raster
#> class : SpatRaster
#> dimensions : 60, 60, 5 (nrow, ncol, nlyr)
#> resolution : 30, 30 (x, y)
#> extent : 685545, 687345, 2103255, 2105055 (xmin, xmax, ymin, ymax)
#> coord. ref. : USA_Contiguous_Albers_Equal_Area_Conic
#> source(s) : memory
#> names : lyr.1, lyr.1, lyr.1, lyr.1, lyr.1
#> min values : 0.005111403, 0.005578907, 0.005050553, 0.005514036, 0.005388717
#> max values : 9.263710010, 8.879008821, 17.824177285, 8.851449690, 12.498338403
plot(dens_raster)