View source: R/random_density.R
| random_density | R Documentation |
The function random_density creates a random density in the study area region_obj. The random density consists of the creation of a number of hotspots nb_simu randomly generated amplitude, size (sigma) and location. The function retruns a density object.
random_density( region_obj, grid_m, density_base, crs, amplitude, sigma, nb_simu )
region_obj |
region object. Region create with the dsims package. |
grid_m |
numeric. Length of the grid (side length of a square in m). |
density_base |
numeric. Density in each cell. |
crs |
numeric. Coordinate system. |
amplitude |
numeric. Minimal and maximal height of the hotspot at its center. |
sigma |
numeric. Minimal and maximal value giving the scale parameter for a gaussian decay. |
nb_simu |
numeric. Number of hotspot to be created. |
For the creation of the baseline density (homogeneous density on the study area) to which this function add randomly hotspot on the study area, the make.density function of the dsims package is used. Then, baseline density density_base as well as the desired grid size to use on the study area grid_m are requested.
density object. The map with the densities for each cell.
library(dsims)
# Create the region object with the make.region function of the dsims package
shapefile.name <- system.file("extdata", "StAndrew.shp", package = "dssd")
region <- make.region(region.name = "St Andrews bay",
shape = shapefile.name,
units = "m")
# Create a random density on the study area (with a 500m square grid) with a baseline density of 10.
# 15 hotspots added with random amplitudes chosen between -5 and 5
# and different sizes (`sigma`) chosen between 2000 and 6000.
density <- random_density(region_obj = region,
grid_m = 500,
density_base = 10,
crs = 2154,
amplitude = c(-5, 5),
sigma = c(2000, 6000),
nb_simu = 15)
# plot(density)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.