View source: R/grib_get_message.R
grib_get_message | R Documentation |
grib_get_message
retrieves a GRIB message from a GRIB file using the
message number.
grib_get_message(gribObj, messages)
gribObj |
|
messages |
an |
grib_get_message
is a quick and easy way to retrieve a GRIB message
from a GRIB file if you know what message number it is. An easy way to
determine the message number is to use grib_list
first (see
examples). 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.frame
s 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.
Returns a gribMessage
object.
grib_select
grib_list
grib_expand_grids
grib_latlons
g <- grib_open(system.file("extdata", "lfpw.grib1", package = "gribr"))
# select one message
gm <- grib_get_message(g, 1)
# select multiple messages
gm_multi <- grib_get_message(g, c(2, 4, 6))
# Use grib_list output to help select messages
msg_loc <- which(grib_list(g)$shortName == "2t") # find 2m temp message
gm_ls <- grib_get_message(g, msg_loc)
grib_close(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.