Description Usage Arguments Details Value See Also Examples
Extracts time series data from a RasterStack for a SpatialPolygons or a SpatialPolygonsDataFrame object.
1 | extractTS(x, y, z, id)
|
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). |
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:
pixel.info - SpatialPointsDataFrame with pixel-wise samples for each polygon (identified by the field id).
polygon.info - Mean, min, max and standard deviation of the pixel cover; centroid coordinates.
weighted.mean - Weighted mean raster values (if y is a raster object).
A list.
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.