Description Usage Arguments Value See Also Examples
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.
1 | featureDensity(feature, raster, weights = 1, ...)
|
feature |
A feature object, anything that is accepted as the |
raster |
A template raster for the resulting density raster. |
weights |
An optional vector of weights, for the elements of |
... |
Other arguments to pass to |
A raster object with the same dimension and resolution as raster
giving the density of features.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.