grib_proj4str: Get PROJ4 string for a GRIB file

View source: R/grib_proj4str.R

grib_proj4strR Documentation

Get PROJ4 string for a GRIB file

Description

grib_proj4str generates a PROJ4 string for a given gribMessage class object based on the message's keys and, optionally, user input.

Usage

grib_proj4str(gribMessage, userProj4 = NULL)

Arguments

gribMessage

gribMessage class object.

userProj4

An optional argument that can be a named list or named character vector of additional PROJ4 elements the user would like to add. User PROJ4 elements take precedence over that given in GRIB file.

Details

grib_proj4str uses a GRIB message's keys to generate a PROJ4 string on the fly. A user can even input their own PROJ4 elements using the userProj4 arugment. Be aware that any user PROJ4 elements that conflict with already present elements will override the elements extracted from the GRIB file. Several other packages have functions that can use this PROJ4 string to appropriately project the values in the GRIB message. Several common grid types are supported at this time, but likely not all.

This function is influenced by the PROJ4 string method used in the pygrib Python module (see pygrib source).

Value

Returns a character string of the PROJ4 elements associate with the gribMessage.

Examples

g <- grib_open(system.file("extdata", "lfpw.grib1", package = "gribr"))
gm <- grib_get_message(g, 1)
grib_proj4str(gm)

# add proj4 parameters, if needed
# overrides proj in this case
grib_proj4str(gm, list(lat_0 = 35, lon_0 = -95, proj = "lcc"))
grib_close(g)

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