| grib_select | R Documentation |
grib_select selects all GRIB messages that match key/value pairs input
by the user.
grib_select(gribObj, keyPairs)
gribObj |
|
keyPairs |
a named |
grib_select is a function more robust than grib_get_message in
that it can search through a GRIB file and get all matching messages given
key(s)/value(s) pairs. This is achieved by making an index of the input GRIB
file and then selecting keys that match user input in keyPairs. The
values returned in the GRIB message are masked if they are coded as a missing
value or the bitmap, if present, masks them.
All grid (latitude, longitude, values, etc.) are output as vectors for
simplicity and flexibility. Many plotting functions want input in
matrix form (e.g., image(), fields::image.plot() while
others want input in long form data.frames or vectors (e.g.,
ggplot). Keeping vector form allows the most flexibility for the user
to do what is needed to format the data appropriately. Some helper functions
in this package will do some data formatting for you.
grib_select is meant as an easy way to grab the data you want.
However, it can suffer from performance issues due to the overhead of
searching through the GRIB file. If speed is important, knowing the message
number in the file and using grib_get_message is the way to go.
Returns a gribMessage or a list of gribMessage objects
if more than one message is selected.
grib_get_message grib_list
grib_expand_grids grib_latlons
g <- grib_open(system.file("extdata", "lfpw.grib1", package = "gribr"))
# select all mixing ratio messages
gm1 <- grib_select(g, list(shortName = "q"))
# select mixing ratio, but only at 1000 and 850 hPa
gm2 <- grib_select(g, list(shortName = "q", level = c(1000, 850)))
grib_close(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.