Description Usage Arguments Value See Also Examples
Given a SpatialPointsDataFrame
object occurrence
with Admin
and GAUL
columns and a RasterBrick
or RasterStack
object admin
giving the admin layers, extract and summarize the values of covariates
using the function fun
for each polygon.
1 | extractAdmin(occurrence, covariates, admin, fun = mean)
|
occurrence |
A |
covariates |
A |
admin |
A |
fun |
A function to summarize the covariate values accross each polygon, |
A matrix giving the summarized covariate values for each of the polygons in occurrence
(i.e. point records will be missing).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # load occurrence data, admin units and covariates
data(occurrence)
data(admin)
data(covariates)
# convert occurrence to an SPDF
occurrence <- occurrence2SPDF(occurrence)
# add on the GAUL codes
occurrence <- getGAUL(occurrence, admin)
# extract all covariates, taking the mean across each polygon
vals <- extractAdmin(occurrence, covariates, admin, fun = mean)
head(vals)
# note that point records are omitted
nrow(occurrence)
nrow(vals)
# it would be better to use different summary functions since cov_c is a factor
cov_ab <- extractAdmin(occurrence, covariates[[1:2]], admin, fun = mean)
cov_c <- extractAdmin(occurrence, covariates[[3]], admin, fun = modal)
head(cbind(cov_ab, cov_c))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.