Get MERRA-2 grid IDs closest to the given coordinates
closest_locid(lon, lat, asList = FALSE)
longitude in degrees (-180 <= lon <= 180)
latitude in degrees (-90 <= lat <= 90)
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.
closest_locid(0, 0)
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> [1] 103969
closest_locid(100.14, -85.145)
#> [1] 6209
closest_locid(0, 89.5, asList = TRUE)
#> [[1]]
#> [1] 207073
#>