View source: R/loadValueStations.R
loadValueStations | R Documentation |
Load observations data from station datasets in the standard VALUE ASCII format (See reference URL).
loadValueStations(
dataset,
var,
stationID = NULL,
lonLim = NULL,
latLim = NULL,
season = NULL,
years = NULL,
tz = ""
)
dataset |
A character string indicating the database to be accessed. This is usually a path to a local file or a URL pointing to a standard ASCII file (.txt) or a .zip file containing station or predictions data. |
var |
Variable code (character string). |
stationID |
Optional. A character vector indicating the code names of the stations to be loaded. |
lonLim |
Vector of length = 2, with minimum and maximum longitude coordinates, in decimal degrees, of the bounding box selected.
For single-point queries, a numeric value with the longitude coordinate. If |
latLim |
Same as |
season |
An integer vector specifying the desired season (in months, January = 1 ..., December = 12).
Options include one to several (contiguous) months. Default to |
years |
Optional vector of years to select. Default ( |
tz |
A time zone specification to be used for the conversion of dates, if one is required
(i.e., if the time zone of the dataset does not correspond to the system-specific one; see
|
a list with the following elements:
Variable
. Name of the variable
Data
. A 2-D matrix containing the data. Dates are ordered by rows and Stations by columns,
following the order indicated in the Metadata
.
xyCoords
. A 2-D matrix with longitude and latitudes of the stations
Dates
. A list with the verification time interval of each record in the time series.
This is represented by a list with two elements: start
and end
, representing the
lower and upper bounds of the verification period
Metadata
. A list of variable length depending on the available metadata associated
to each observation. If no metadata are provided, at least the station codes (compulsory) are displayed.
Regarding the selection of the spatial domain,
it is possible to select the whole spatial domain of a dataset by defining the arguments lonLim=NULL
and latLim=NULL
. Arbitrary rectangular domains are defined by the minimum and maximum coordinates
in longitude and latitude (for instance lonLim=c(-10,10)
and latLim=c(35,45)
indicates a
rectangular window centered in the Iberian Peninsula), and single grid-cell values
(for instance lonLim=-3.21
and latLim=41.087
for retrieving the data in the closest grid
point to the point coordinate -3.21E, 41.087N. In the last two cases, the function
operates by finding the nearest (euclidean distance) grid-points to the coordinates introduced.
In the case of station data (loadValueStations
), the logic is the same, taking into account that in the case
of rectangular domains, all stations falling inside that window will be loaded. For single-point selections,
the closest station will be chosen, and a note on-screen will inform about the distance from the selected point
to the chosen station.
Unlike gridded datasets, station data do not use a dictionary for variable homogenization. Thus, users must take care of variable units and eventual conversions when necessary.
J. Bedia
VALUE's standard ASCII format reference: http://meteo.unican.es/work/loadeR/wiki/Rmd_html/OformatStationData.html http://stackoverflow.com/questions/12460938/r-reading-in-a-zip-data-file-without-unzipping-it
Other loading:
loadStationPredictions()
## Not run:
obs.dataset <- file.path(find.package("VALUE"), "example_datasets", "VALUE_ECA_86_v2.zip")
# All data
obs <- loadValueStations(dataset = obs.dataset, var = "tmean")
# Selection by lon-lat
obs1 <- loadValueStations(dataset = obs.dataset, var = "tmax", lonLim = -3, latLim = 42)
obs1$Metadata
# Selection by station code
obs2 <- loadValueStations(dataset = obs.dataset, var = "tmax", stationID = "000232")
obs2$Metadata
# Several stations within a rectangular domain
obs3 <- loadValueStations(obs.dataset, "precip", lonLim = c(-5, 2), latLim = c(38, 43))
obs3$Metadata
# Winter data for 1991-2000
djf <- loadValueStations(dataset = obs.dataset, var = "tmin", season = c(12, 1, 2),
years = 1991:2000)
# Note that winter 1991 encompasses Dec 1990 + Jan 1991 + Feb 1991 (year-crossing season)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.