|Extract by index||R Documentation|
This is a short-hand method that acts the same as
extract. This method extracts values from a
Raster*TS object for spatial locations which can be specified by spatial points, lines, polygons, or an Extent (rectangle) object or raster cell number(s).
This function uses the raster and xts packages to extract the values in space and subset them in time by specifying ISO-8601 compatible range strings. This allows for natural range-based time queries without requiring prior knowledge of the underlying time object used in construction.
When a raw character vector is used for
j, it is processed as if it was ISO-8601 compliant. This means that it is parsed from left to right, according to the following specification:
A full description will be expanded from a left-specified truncated one.
Additionally, one may specify range-based queries by simply supplying two time descriptions seperated by a forward slash:
CCYYMMDD HH:MM:SS.ss+/CCYYMMDD HH:MM:SS.ss
The algorithm to parse the above is
the xts package.
x is a raster time series (
Raster*TS) object created by
i is a
Extent object, or a vector (representing cell numbers)
j is optional; the time index for which the values in raster should be extracted. It can be numeric, timeBased or ISO-8601 style (see details)
## Not run: file <- system.file("external/ndvi", package="rts") ndvi <- rts(file) # read the ndvi time series from the specified file n1 <- ndvi # extract the time series values at cell number 125 for all available times n1 plot(n1) n2 <- ndvi[125,"/20090101"] # extract the time series values at cell number 125 for # all times after 2009-01-01 n2 plot(n2) n3 <- ndvi[125,"200901/"] # extract the time series values at cell number 125 for all # times before 2009-01 n4 <- ndvi[10:20,"2008-05-01"] #extract the values at cell numbers of 10:20 for # the specified time n4 ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.