extractTS: extractTS

Description Usage Arguments Details Value See Also Examples

View source: R/extractTS.R

Description

Extracts time series data from a RasterStack for a SpatialPolygons or a SpatialPolygonsDataFrame object.

Usage

1
extractTS(x, y, z, id)

Arguments

x

Object of class SpatialPolygons, SpatialPolygonsDataFrame, SpatialPoints or SpatialPointsDataFrame.

y

A raster object, a list of RasterLayer objects or a numeric element.

z

Numeric vector with weights for each element in x (when points).

id

Numeric vector with unique identifiers for x (when points).

Details

For each polygon in x - if x is a SpatialPolygons and SpatialPolygonsDataFrame object - the function identifies the overlapping pixels in y and, for each pixel, estimates the percentage area covered by the polygon. Using this data as weights, the function calculates the weighted mean for each band in y. If y is a numeric element, the function will build a raster with resolution equal to y over which the pixel cover will be estimated. Moreover, if x is a SpatialPoints or a SpatialPointsDataFrame object, the function will skip the pixel extraction step. In this case, the user may provide a vector with sample weights through z and a vector of unique identifiers (reporting on e.g. the polygon membership) The function returns a list of three data.frame objects where each row represents a different polygon in x:

Value

A list.

See Also

analyseTS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{

require(raster)
require(fieldRS)

# read raster data
r <- brick(system.file("extdata", "ndvi.tif", package="fieldRS"))

# read field data
data(fieldData)

extractTS(fieldData[1:5,], r)

}

CAWaR documentation built on July 8, 2020, 7:06 p.m.