Reads a NetCDF file into a data frame with longitude and latitude information

nc_to_df(
  obj,
  varnam,
  lon = NA,
  lat = NA,
  do_get_ilon_ilat = FALSE,
  dropna = FALSE,
  filn = NA,
  verbose = FALSE
)

Arguments

obj

Either character string specifying the NetCDF file path to be read or a object returned by function GECOr::read_nc_onefile() or GECOr::nc_to_df().

varnam

A character string specifying the variable name in the NetCDF file.

lon

A numeric vector specifying longitude values. Defaults to NA.

lat

A numeric vector specifying latitude values. Defaults to NA.

do_get_ilon_ilat

A boolean specifying whether longitude and latitude indices are added to the data frame. Defaults to FALSE.

dropna

A boolean specifying wether rows where the data variable is NA should be dropped. Recommended to be set to TRUE for large global arrays where much of the grid is NA (e.g., over ocean).

filn

A character string specifying the file name to which the data frame is written. If filn = NA (defaults), the data frame is returned by the function, otherwise, NULL is returned.

verbose

A boolean specifying whether progress messages should be written to prompt.

Value

A data frame if filn == NA, otherwise nothing is returned.