Skip to contents

Get MERRA-2 grid IDs closest to the given coordinates

Usage

closest_locid(lon, lat, asList = FALSE)

Arguments

lon

longitude in degrees (-180 <= lon <= 180)

lat

latitude in degrees (-90 <= lat <= 90)

asList

Value

integer vector with locations IDs (locid) when `asList` is FALSE (default). In the case of several values, only the first `locid` will be returned. If `asList` is TRUE, a list is returned with possible multiple values for each coordinate.

Examples

closest_locid(0, 0)
#> [1] 103969
closest_locid(100.14, -85.145)
#> [1] 6209
closest_locid(0, 89.5, asList = TRUE)
#> [[1]]
#> [1] 207073
#>