Skip to content

hypertidy/location

Repository files navigation

location

R-CMD-check

Minimal geocoding for R via Nominatim (OpenStreetMap). No API key required.

Installation

pak::pak("hypertidy/location")

Usage

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"

Design

  • 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 fields
  • api_url can point to a local Nominatim instance
  • Enforces 1 req/sec and sets a meaningful User-Agent per Nominatim policy
  • curl::has_internet() guard — returns NA rows silently offline

Used by

Dependencies

  • curl — HTTP
  • jsonlite — JSON parsing
  • lutz (suggested) — for loc_tz()

Code of Conduct

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.

About

Geocode Place Names via Nominatim

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages