griddap {rerddap}R Documentation

Get ERDDAP gridded data

Description

Get ERDDAP gridded data

Usage

griddap(x, ..., fields = "all", stride = 1, fmt = "nc", url = eurl(),
  store = disk(), read = TRUE, callopts = list())

Arguments

x

Anything coercable to an object of class info. So the output of a call to info, or a datasetid, which will internally be passed through info

...

Dimension arguments. See examples. Can be any 1 or more of the dimensions for the particular dataset - and the dimensions vary by dataset. For each dimension, pass in a vector of length two, with min and max value desired.

fields

(character) Fields to return, in a character vector.

stride

(integer) How many values to get. 1 = get every value, 2 = get every other value, etc. Default: 1 (i.e., get every value)

fmt

(character) One of csv or nc (for netcdf). Default: nc

url

A URL for an ERDDAP server. Default: http://upwell.pfeg.noaa.gov/erddap/

store

One of disk (default) or memory. You can pass options to disk

read

(logical) Read data into memory or not. Does not apply when store parameter is set to memory (which reads data into memory). For large csv, or especially netcdf files, you may want to set this to FALSE, which simply returns a summary of the dataset - and you can read in data piecemeal later. Default: TRUE

callopts

Pass on curl options to GET

Details

Details:

If you run into an error like "HTTP Status 500 - There was a (temporary?) problem. Wait a minute, then try again.". it's likely they are hitting up against a size limit, and they should reduce the amount of data they are requesting either via space, time, or variables. Pass in config = verbose() to the request, and paste the URL into your browser to see if the output is garbled to examine if there's a problem with servers or this package

Value

An object of class griddap_csv if csv chosen or griddap_nc if nc file format chosen. These two classes are a thin wrapper around a data.frame, so the data you get back is a data.frame with metadata attached as attributes (datasetid, path (path where the nc or csv is stored on your machine), url (url for the request)), along with a summary of the netcdf file (if fmt="nc"). If read=FALSE, you get back an empty data.frame

Dimensions and Variables

ERDDAP grid dap data has this concept of dimenions vs. variables. Dimensions are things like time, latitude, longitude, altitude, and depth. Whereas variables are the measured variables, e.g., temperature, salinity, air.

You can't separately adjust values for dimensions for different variables. So, here's how it's gonna work:

Pass in lower and upper limits you want for each dimension as a vector (e.g., c(1,2)), or leave to defaults (i.e., don't pass anything to a dimension). Then pick which variables you want returned via the fields parameter. If you don't pass in options to the fields parameter, you get all variables back.

To get the dimensions and variables, along with other metadata for a dataset, run info, and each will be shown, with their min and max values, and some other metadata.

Where does the data go?

You can choose where data is stored. Be careful though. You can easily get a single file of hundreds of MB's (upper limit: 2 GB) in size with a single request. To the store parameter, pass memory if you want to store the data in memory (saved as a data.frame), or pass disk if you want to store on disk in a file. Note that memory and disk are not character strings, but function calls. memory does not accept any inputs, while disk does. Possibly will add other options, like “sql” for storing in a SQL database.

Author(s)

Scott Chamberlain <myrmecocystus@gmail.com>

References

http://upwell.pfeg.noaa.gov/erddap/rest.html

Examples

## Not run: 
# single variable dataset
## You can pass in the outpu of a call to info
(out <- info('noaa_esrl_027d_0fb5_5d38'))
(res <- griddap(out,
 time = c('2012-01-01','2012-06-12'),
 latitude = c(21, 18),
 longitude = c(-80, -75)
))
## Or, pass in a dataset id
(res <- griddap('noaa_esrl_027d_0fb5_5d38',
 time = c('2012-01-01','2012-06-12'),
 latitude = c(21, 18),
 longitude = c(-80, -75)
))

# multi-variable dataset
(out <- info('erdQMekm14day'))
(res <- griddap(out,
 time = c('2015-12-28','2016-01-01'),
 latitude = c(24, 23),
 longitude = c(88, 90)
))
(res <- griddap(out, time = c('2015-12-28','2016-01-01'),
   latitude = c(24, 23), longitude = c(88, 90), fields = 'mod_current'))
(res <- griddap(out, time = c('2015-12-28','2016-01-01'),
   latitude = c(24, 23), longitude = c(88, 90), fields = 'mod_current',
   stride = c(1,2,1,2)))
(res <- griddap(out, time = c('2015-12-28','2016-01-01'),
   latitude = c(24, 23), longitude = c(88, 90),
   fields = c('mod_current','u_current')))

(out <- info('noaa_esrl_4965_b6d4_7198'))
(res <- griddap(out,
 time = c('1990-10-01', '1991-02-01'),
 latitude = c(20, 21),
 longitude = c(2, 5)
))

# Write to memory (within R), or to disk
(out <- info('erdQSwindmday'))
## disk, by default (to prevent bogging down system w/ large datasets)
## you can also pass in path and overwrite options to disk()
(res <- griddap(out,
 time = c('2006-07-11','2006-07-20'),
 longitude = c(166, 170),
 store = disk()
))
## the 2nd call is much faster as it's mostly just the time of reading in
## the table from disk
system.time( griddap(out,
 time = c('2006-07-11','2006-07-15'),
 longitude = c(10, 15),
 store = disk()
) )
system.time( griddap(out,
 time = c('2006-07-11','2006-07-15'),
 longitude = c(10, 15),
 store = disk()
) )

## memory
(res <- griddap("erdMBchla1day",
 time = c('2015-01-01','2015-01-03'),
 latitude = c(14, 15),
 longitude = c(125, 126),
 store = memory()
))

## Use ncdf4 package to parse data
info("erdMBchla1day")
(res <- griddap("erdMBchla1day",
 time = c('2015-01-01','2015-01-03'),
 latitude = c(14, 15),
 longitude = c(125, 126)
))

# Get data in csv format
## by default, we get netcdf format data
(res <- griddap('erdMBchla1day',
 time = c('2015-01-01','2015-01-03'),
 latitude = c(14, 15),
 longitude = c(125, 126),
 fmt = "csv"
))

# Use a different ERDDAP server url
## NOAA IOOS PacIOOS
url = "http://oos.soest.hawaii.edu/erddap/"
out <- info("NOAA_DHW", url = url)
(res <- griddap(out,
 time = c('2005-11-01','2006-01-01'),
 latitude = c(21, 20),
 longitude = c(10, 11)
))
## pass directly into griddap()
griddap("NOAA_DHW", url = url,
 time = c('2005-11-01','2006-01-01'),
 latitude = c(21, 20),
 longitude = c(10, 11)
)

# You don't have to pass in all of the dimensions
## They do have to be named!
griddap(out, time = c('2005-11-01','2005-11-03'))

# Using 'last'
## with time
griddap('noaa_esrl_fce0_4aad_340a',
 time = c('last-5','last'),
 latitude = c(21, 18),
 longitude = c(3, 5)
)
## with latitude
griddap('noaa_esrl_fce0_4aad_340a',
  time = c('2008-01-01','2009-01-01'),
  latitude = c('last', 'last'),
  longitude = c(3, 5)
)
## with longitude
griddap('noaa_esrl_fce0_4aad_340a',
 time = c('2008-01-01','2009-01-01'),
 latitude = c(21, 18),
 longitude = c('last', 'last')
)

## End(Not run)

[Package rerddap version 0.4.2 Index]