Minimal geocoding for R via Nominatim (OpenStreetMap). No API key required.
# pak::pak("hypertidy/location")
install.packages("location", repos = c('https://hypertidy.r-universe.dev', 'https://cloud.r-project.org'))
library(location)
# Single place
loc("Hobart, Tasmania")
#> lon lat name
#> 1 147.3281 -42.88251 Hobart, City of Hobart, Tasmania, Australia
#> query osm_type
#> 1 Hobart, Tasmania relation
# Multiple places - one request per second (Nominatim policy)
loc(c("Davis Station, Antarctica", "Casey Station", "Mawson Station"))
#> lon lat name query osm_type
#> 1 NA NA <NA> Davis Station, Antarctica <NA>
#> 2 110.52408 -66.28209 Casey Station Casey Station node
#> 3 62.87375 -67.60290 Mawson Station Mawson Station node
# Straight to timezone (requires lutz)
loc_tz("Crystal Lake, TN")
#> [1] "America/New_York"
loc_tz(c("Hobart", "McMurdo Station", "Rothera"))
#> [1] "Australia/Hobart" "Antarctica/McMurdo" "Antarctica/Rothera"
loc(x) → data frame: query, lat, lon, display_name,
osm_type
loc_tz(x) → character vector of IANA tz names (requires lutz)full = TRUE returns all Nominatim response fieldsapi_url can point to a local Nominatim instanceUser-Agent per Nominatim
policy
curl::has_internet() guard — returns NA rows silently offlinecurl — HTTPjsonlite — JSON parsinglutz (suggested) — for loc_tz()
Please note that the location project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.