View source: R/loadStationData.R
loadStationData | R Documentation |
Load observations data from station datasets in standard ASCII format.
loadStationData(
dataset,
var,
stationID = NULL,
lonLim = NULL,
latLim = NULL,
season = NULL,
years = NULL,
tz = "",
projection = "+proj=longlat +init=epsg:4326 +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0",
units = NULL,
level = NULL,
spatialTolerance = NULL
)
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 netCDF or NcML file in the case of netCDF and/or gridded datasets. For station data in standard ASCII format, this is the path to the directory the dataset lives in. |
var |
Variable code (character string). This is the name of the variable according to the R standard naming
(see the next argument). For variables with vertical levels, the vertical level is specified next to the variable name followed
by the “@” symbol (e.g. |
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
|
projection |
Optional. Coordinate projection that is passed to attribute |
units |
Optional (but strongly advised when possible). This is a character string indicating the units
of the variable. This should be whenever possible compatible with the udunits valid (“parseable”)
definitions. See |
level |
Optional character of the atmospheric level. This information about the variable will be included in the output grid. Requires knowledge about the dataset. |
spatialTolerance |
Numeric. The use of this argument is NOT RECOMMENDED. Distance (in grid coordinate units) out of the lonLim and LatLim ranges that is allowed for data retrieving. |
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 the dataset by defining the arguments lonLim=NULL
and latLim=NULL
. More often, 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 (loadStationData
), 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.
In case of irregular grids (e.g. the typical RCM rotated pole projections), the regular coordinates are included in the
x
and y
elements of the xyCoords
list, while the corresponding geographical coordinates are insode two matrices inside
the lon
and lat
elements.
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
https://github.com/SantanderMetGroup/loadeR/wiki/Standard-(ASCII)-format-for-station-data
Other loading:
loadCircularGridData()
,
loadGridData()
,
makeAggregatedDataset()
## Not run:
## This example is further illustrated in the loadeR's wiki at:
## <https://github.com/SantanderMetGroup/loadeR/wiki/Accessing-and-loading-station-data>
# Download the VALUE-ECA-86 dataset (https://rmets.onlinelibrary.wiley.com/doi/10.1002/joc.5462) as a temp file
value <- tempfile(fileext = ".zip")
download.file("www.value-cost.eu/sites/default/files/VALUE_ECA_86_v2.zip", destfile = value)
stationInfo(value)
example <- loadStationData(dataset = value,
var = "tmax",
stationID = c("000234", "003946"),
season = 6:8,
years = 1981:2000)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.