nc_write_map: Write a data.frame containing data on a geographical grid as...

Description Usage Arguments Examples

View source: R/nc_write.R

Description

Write a data.frame containing data on a geographical grid as a netCDF file

Usage

1
2
nc_write_map(d, file, dimensions = c("lon", "lat"), units = NULL,
  attributes = NULL, crs = "WGS84", ...)

Arguments

d

data.frame containing coordinates (along dimensions) and variables

file

output file path

dimensions

names or indexes of columns in d representing the data dimensions

units

named vector or list containing character strings which specify the units of dimensions and variables. The names must be those of columns in d. Defaults to no unit

attributes

list of lists containing attributes (second-level lists) for each dimension and variable (first level list). The list must be named with names which are dimensions or variables (i.e. columns of d). Each second-level list is also a named list which stores attributes as key/value pairs, where the key is the name of the element of the list and the value is the content of that element

crs

Coordinate Reference System specification. Currently only WGS84 is supported.

...

passed to nc_write

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# load altitude data over the Mediterranean Sea
data(med)
file_name <- tempfile()
nc_write_map(med, file=file_name,
  # dimensions are lon and lat by default
  # variables are all other columns (altitude)
  # units of lon and lat are set automatically
  units = c(altitude="m"),
  # as are attributes
  attributes = list(
    altitude = list(long_name="Altitude relative to mean sea level", standard_name="altitude") 
  ),
  # some global attributes are set automatically. Those will be added
  global.attributes = list(
    author = "Pr Foobar",
    date_created = "2014-06-19"
  )
)

jiho/ncdf4helpers documentation built on May 19, 2019, 10:31 a.m.