R/location_getOpenCageInfo.R
location_getOpenCageInfo.Rd
The OpenCage reverse geocoding service is used to obtain all available information for a specific location.
The data from OpenCage should be considered to be the gold standard for address information could and should be used to override information we get elsewhere.
location_getOpenCageInfo(longitude = NULL, latitude = NULL, verbose = FALSE)
Single longitude in decimal degrees E.
Single latitude in decimal degrees N.
Logical controlling the generation of progress messages.
Single-row tibble with OpenCage information.
The OpenCage service requires an API key which can be obtained from their web site. This API key must be set as an environment variable with:
Sys.setenv("OPENCAGE_KEY" = "YOUR_PERSONAL_API_KEY")
The OpenCage "free trial" level allows for 1 request/sec and a maximum of 2500 requests per day.
# \donttest{
library(MazamaLocationUtils)
# Fail gracefully if any resources are not available
try({
# Wenatchee
lon <- -120.325278
lat <- 47.423333
Sys.setenv("OPENCAGE_KEY" = "YOUR_PERSONAL_API_KEY")
openCageTbl <- location_getOpenCageInfo(lon, lat)
dplyr::glimpse(openCageTbl)
}, silent = FALSE)
#> Warning: Unauthorized (HTTP 401).
#> Error: invalid API key
#> Rows: 1
#> Columns: 3
#> $ lat <dbl> 47.42333
#> $ long <dbl> -120.3253
#> $ address <chr> NA
# }