knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(intercali)

Create random densities

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.

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.

Example

An example of this function uses a study area from the package dssd and creates the region object thanks to the package dsims and the function make.region.

From this region object (with a 500m square grid), the aim is to create a random density. Here the baseline density of the study region is 10, then the function add 15 hotspots in the study region with random amplitudes chosen between -5 and 5 and different sizes (sigma) chosen between 2000 and 6000.

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)


maudqueroue/intercali documentation built on Oct. 8, 2022, 2:09 p.m.