featureDensity: Create a raster of the density of points and polygons

Description Usage Arguments Value See Also Examples

Description

Given a feature object (feature) and a template raster (raster), create a raster giving the density of features at each cell. The density of polygons can be split accross multiple cells be providing a vector of weights via the weights argument. This is essentially a wrapper to rasterize in the raster package.

Usage

1
featureDensity(feature, raster, weights = 1, ...)

Arguments

feature

A feature object, anything that is accepted as the x argument in rasterize.

raster

A template raster for the resulting density raster.

weights

An optional vector of weights, for the elements of feature or a string giving a column of feature containing weights. This is passed to the field argument in rasterize, so read that helpfile for more details.

...

Other arguments to pass to rasterize.

Value

A raster object with the same dimension and resolution as raster giving the density of features.

See Also

rasterize

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#
# create a raster
r <- raster(nrows = 10, ncols = 10,
              xmn = 0, xmx = 10,
              ymn = 0, ymx = 10)
r <- setValues(r, round(runif(ncell(r)) * 10))

# and some points
pts <- xyFromCell(r,
                  sample(1:ncell(r), 500, replace = TRUE))

# some fake weights
wts <- runif(nrow(pts))
                  
# calculate their density
density <- featureDensity(pts, r, weights = wts)

SEEG-Oxford/seegSDM documentation built on May 9, 2019, 11:08 a.m.