get_timeseries {climatrends} | R Documentation |
Time series climate data
Description
General functions and methods to concatenate climate data across a time series
Usage
get_timeseries(object, day.one, ...)
## Default S3 method:
get_timeseries(
object,
day.one,
span = NULL,
last.day = NULL,
as.matrix = FALSE,
data.from = "nasapower",
...
)
## S3 method for class 'matrix'
get_timeseries(object, day.one, span = NULL, last.day = NULL, ...)
## S3 method for class 'array'
get_timeseries(object, day.one, span = NULL, last.day = NULL, ...)
Arguments
object |
a |
day.one |
a vector of class |
... |
additional arguments passed to methods. See details. |
span |
an integer or a vector with integers (optional if last.day is given) for the length of the time series to be captured |
last.day |
optional to span, an object of class |
as.matrix |
logical, optional, to return a matrix or array instead of a data.frame |
data.from |
character, for the source of climate data. See details. |
Details
The default
method and the sf
method assumes that the climate
data will be fetched from an remote (cloud) data.from.
The matrix
method assumes that the climate data was previously handled
and will be inputted in the format of a named matrix.
See help("modis", "climatrends") for examples.
Available remote sources to pass data.from: "nasapower"
Additional arguments:
pars
: character vector of solar, meteorological or climatology parameters
to download. See help("parameters", "nasapower") when data.from = "nasapower".
days.before
: an integer for the number of days before day.one to be
included in the timespan.
Value
A list with class clima_ls
with data.frame(s) with
the class clima_df
Examples
# Using local sources
# an array with temperature data
data("temp_dat", package = "climatrends")
set.seed(9271)
span <- as.integer(runif(10, 6, 15))
get_timeseries(temp_dat, "2013-10-28", span = span)
# matrix with precipitation data
data("rain_dat", package = "climatrends")
get_timeseries(rain_dat, "2013-10-28", span = span)
# data can be returned as matrix
library("sf")
# Fetch data from NASA POWER using 'sf' method
data("lonlatsf", package = "climatrends")
g <- get_timeseries(object = lonlatsf,
day.one = "2018-05-16",
last.day = "2018-05-30",
pars = c("PRECTOTCORR", "T2M"),
as.matrix = TRUE)