apply.monthly: Apply a function over calendar periods

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Apply a specified function to each distinct period in a given raster time series object.

Usage

1
2
3
4
5
apply.daily(x, FUN, ...)
apply.weekly(x, FUN, ...)
apply.monthly(x, FUN, ...)
apply.quarterly(x, FUN, ...)
apply.yearly(x, FUN, ...)

Arguments

x

a raster time series (Raster*TS) object, created by rts

FUN

an R function

...

additional arguments to FUN

Details

These functions offer Simple mechanism to apply a function to non-overlapping time periods, e.g. weekly, monthly, etc, and return a raster time series object including a raster layer for each period in the original data, produced by FUN. The end of each period of time is assigned to the corresponding raster layer in the output.

Value

A raster time series (Raster*TS) object

Author(s)

Babak Naimi

naimi.b@gmail.com

http://r-gis.net

See Also

endpoints, period.apply,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
file <- system.file("external/ndvi", package="rts")

ndvi <- rts(file) # read the ndvi time series from the specified file
ndvi
ndvi.y <- apply.yearly(ndvi, mean) # apply mean function for each year
ndvi.y
ndvi.q <- apply.quarterly(ndvi,sd) # apply sd function for each quarter of years
ndvi.q 

## End(Not run)

Example output

Loading required package: sp
Loading required package: raster
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: RCurl
Loading required package: bitops
rts 1.0-49 (2019-02-01)
Raster Time Series with monthly periodicity from 2000-02-01 01:00:00 to 2009-12-01 01:00:00 
class       : RasterBrickTS 
raster filename    : /usr/lib/R/site-library/rts/external/ndvi/ndvi.grd 
raster dimensions  : 30, 43, 1290, 113  (nrow, ncol, ncell, nlayers)
raster resolution  : 1000, 1000  (x, y)
raster extent      : 631900.5, 674900.5, 5714611, 5744611  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
min values  : -0.026  0.234  0.243  0.280  0.257  0.118  0.287  0.283  0.408  0.284 ... 
max values  : 0.79 0.85 0.85 0.87 0.89 0.93 0.88 0.86 0.82 0.82 ... 

Raster Time Series with yearly periodicity from 2000-12-01 01:00:00 to 2009-12-01 01:00:00 
class       : RasterBrickTS 
raster dimensions  : 30, 43, 1290, 10  (nrow, ncol, ncell, nlayers)
raster resolution  : 1000, 1000  (x, y)
raster extent      : 631900.5, 674900.5, 5714611, 5744611  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
min values  : 0.27 0.27 0.28 0.26 0.28 0.26 0.25 0.28 0.28 0.28 
max values  : 0.82 0.80 0.79 0.77 0.80 0.82 0.77 0.83 0.79 0.81 

Raster Time Series with quarterly periodicity from 2000-03-01 01:00:00 to 2009-12-01 01:00:00 
class       : RasterBrickTS 
raster filename    : /work/tmp/tmp/RtmpZ0ZsZZ/raster/r_tmp_2019-11-08_204222_24809_04322.grd 
raster dimensions  : 30, 43, 1290, 40  (nrow, ncol, ncell, nlayers)
raster resolution  : 1000, 1000  (x, y)
raster extent      : 631900.5, 674900.5, 5714611, 5744611  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
min values  : 0.0e+00 1.4e-03 1.2e-03 1.4e-03 3.2e-04 5.8e-05 1.0e-03 5.0e-04 3.2e-04 1.1e-03 ... 
max values  : 0.33 0.24 0.36 0.21 0.25 0.24 0.16 0.15 0.15 0.27 ... 

rts documentation built on May 2, 2019, 4:49 p.m.

Related to apply.monthly in rts...