grib_get_message: Get GRIB messages

View source: R/grib_get_message.R

grib_get_messageR Documentation

Get GRIB messages

Description

grib_get_message retrieves a GRIB message from a GRIB file using the message number.

Usage

grib_get_message(gribObj, messages)

Arguments

gribObj

GRIB class object.

messages

an integer or vector of integers corresponding to the messages to extract from the GRIB file.

Details

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.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.

Value

Returns a gribMessage object.

See Also

grib_select grib_list grib_expand_grids grib_latlons

Examples

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)

nawendt/gribr documentation built on Oct. 24, 2023, 6:19 a.m.