sortPolyData: Organise polygon count data for modelling.

Description Usage Arguments Value See Also Examples

Description

Takes polygons, an occurrence dataset and covariates. Returns a data.frame containing centroid coordinates, count of occurrence points and a summary of covariate values for each polygon. Includes an option to specify the function to apply across pixel values for each covariate. The default is mean.

Usage

1
2
sortPolyData(polygons, data, covariates, fun = rep("mean",
  nlayers(covariates)))

Arguments

polygons

an object of SpatialPolygons class.

data

a data.frame containing at least columns Longitude and Latitude

covariates

a RasterStack

fun

vector of length equalling the number of covariates specifying the function to be applied across pixel values within each polygon for each covariate. The default is 'mean'. Functions must be entered as strings and 'modal' should be specified for discrete variables.

Value

A data.frame of, for each polygon, centroid coordinates, counts of occurrence points and a summary of covariate values.

See Also

Other GIS: bufferMask, condSim, getArea, getPoints, insertRaster, ll2cart, makeVoronoiPolygons, safeMask

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# load packages
library(sp)
library(raster)
library(seegSDM)

# make voronoi polygons
example(makeVoronoiPolygons)

# make occcurrence data
occ <- matrix(c(-5, 0,
                 -1, 6,
                 -8, 8,
                 -8, 7,
                 -5, 10),
             ncol=2,
             byrow=TRUE)

# convert to dataframe
occ <- as.data.frame(occ)

# add Longitude and Latitude columns
colnames(occ)[colnames(occ)=='V1'] <- 'Longitude'
colnames(occ)[colnames(occ)=='V2'] <- 'Latitude'

# load covariates from seegSDM
data(covariates)

# make functions vector
fun = c('mean', 'mean', 'modal')

# sort data
dat <- sortPolyData(polygons = v, data = occ, covariates=covariates, fun=fun)

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