dataFromGrid | R Documentation |
This function extracts data from a gridded dataset based on given coordinates.
dataFromGrid(grid, varname, lon, lat, times = FALSE)
grid |
a RasterBrick or RasterStack object or a path to a NetCDF file. |
varname |
a character string specifying the name of the variable to extract in NetCDF file. |
lon |
numeric vector with longitude(s) of target location(s). |
lat |
numeric vector with latitude(s) of target location(s). |
times |
logical. If TRUE, time dimension will be extracted from data and the returned values will be in form of a zoo object. Only works for NetCDF and RasterBrick. |
The argument time searches the time dimension and its units in the gridded dataset (NetCDF or RasterBrick). If it can't be found, only the data will be returned.
Arguments lon and lat define the coordinates that must be in the same projection as the gridded dataset. If there is no spatial coincidence, returned object will be empty.
A matrix with same columns as pairs of coordinates defined in lon and lat arguments. If times is TRUE, the matrix will be a zoo object.
try( dataFromGrid(grid = "tmax.nc", varname = 'tn', lon = c(41.39, 42), lat = c(2.17, 2.5), times = FALSE) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.