Learn R Programming

DSsim (version 1.1.4)

make.density: Creates a Density object

Description

The user has the option to create a grid describing the density of the objects and pass this in giving the x and y spacings used in the creation of this grid. Alternatively the user can specify a constant density and x, y spacings and this grid will be generated automatically. The user may also supply a mgcv gam object and x, y spacings and the density grid will be created from these.

Usage

make.density(region.obj = make.region(), density.surface = list(),
  x.space = 5, y.space = NULL, buffer = numeric(0),
  constant = numeric(0), density.gam = NULL, dsm = NULL,
  formula = NULL)

Arguments

region.obj

the Region object in which the density grid will be created

density.surface

Object of class list; list of data.frames with the columns x, y and density. There must be one data.frame for each strata.

x.space

the intervals in the grid in the x direction

y.space

the intervals in the grid in the y direction

buffer

the width of the buffer region for generating the density grid. If not supplied DSsim will use the maximum value provided for the x.space or y.space.

constant

a value describing a constant density across the surface. If not supplied a default value of 1 is used for all strata.

density.gam

gam object created using mgcv with only x and y as explanatory covariates.

dsm

not currently implemented

formula

not currently implemented

Value

object of class Density

See Also

make.region

Examples

Run this code
# NOT RUN {
 
# A simple density surface with a constant value of 1 can be created within a rectangular 
# region using 
# the default values:
density <- make.density()
plot(density)
plot(make.region(), add = TRUE)
  
# The example below shows hot to add high and low point to the density surface                   
# }
# NOT RUN {
pop.density <- make.density(region.obj = region, x.space = 10, 
 y.space = 10, constant = 0.5) 
 
pop.density <- add.hotspot(pop.density, centre = c(50, 200), 
 sigma = 100, amplitude = 0.1)
pop.density <- add.hotspot(pop.density, centre = c(500, 700), 
 sigma = 900, amplitude = 0.05)
pop.density <- add.hotspot(pop.density, centre = c(300, 100), 
 sigma = 100, amplitude = -0.15)

#New plot features
plot(pop.density)
plot(region, add = TRUE)

#Block style plotting
plot(pop.density, contours = FALSE, style = "blocks")
plot(region, add = TRUE)

# }

Run the code above in your browser using DataLab