read_nc: Read netCDF file containing the gridded data.

View source: R/read_nc.R

read_ncR Documentation

Read netCDF file containing the gridded data.

Description

This function read the netCDF (.nc) file associated with the varname argument, extract the data and slice it according to specified arguments. The function return a list containing the sliced data, its coordinates and others useful metadata.

Usage

read_nc(
  varname,
  longitude = NA,
  latitude = NA,
  time = NA,
  path_to_data = NA,
  date_format = "%Y-%m"
)

Arguments

varname

Name of the variable

longitude

Default = NA, Range of longitude to slice the variable data. If NA, the whole dimensions is imported. The longitude argument must be NA or a vector of length 2.

latitude

Default = NA, Range of latitude to slice the variable data. If NA, the whole dimension is imported. The latitude argument must be NA or a vector of length 2.

time

Default = NA, Range of time to slice the variable data. If NA, the whole dimension is imported. The time argument must be NA or a vector of length 2.

path_to_data

Default = NA. The path to the data directory. If NA, the path is store in /extdata/pkg_params.rdata under the name data_path

date_format

Default = " Default can be seen as "YYYY-MM". Other possible format are available via strptime

Value

Return a list containing the sliced data, its dimensions and their values and the variable units.

To get all the possible field names, use the command names. Example : names(var_data)

Examples

## Not run: var = read_nc("bottom_temperature")

var = read_nc("bottom_temperature", longitude=c(-64,-50), latitude=c(34,50),
time = c("1985-01","2004-11"))
## End(Not run)


BSt-Denis/gslcoenv documentation built on Feb. 10, 2023, 7:53 a.m.