The goal of rreversegeocoder is to, given latitude and longitude, find the nearest city in US.

Installation

You can install the development version of rreversegeocoder from GitHub with:

remotes::install_github("jrosell/rreversegeocoder")

Example

This is a basic example which shows you how to get all the geoname information from a given latitude and longitude in US:

library(tidyverse)
library(tidymodels)
library(rreversegeocoder)

cites <- download_cities_with_population_5000()

input <- tribble(
    ~latitude, ~longitude,
    34.6, -120,
    34.1, -100
)

output <- input |>
    bind_cols(reverse_geocoder_us_cities_with_population_5000(input)) |>
    left_join(cites, by = "geonameid")

glimpse(output)
Rows: 2
Columns: 21
$ latitude           34.6, 34.1
$ longitude          -120, -100
$ geonameid          "5397059", "4739078"
$ name               "Solvang", "Vernon"
$ asciiname          "Solvang", "Vernon"
$ alternatenames     "Solvang,Solvang i California,Solvanq,Solveng,solbhya…
$ geoname_latitude   34.59582, 34.15536
$ geoname_longitude  -120.13765, -99.26628
$ feature_class      "P", "P"
$ feature            "PPL", "PPLA2"
$ country            "US", "US"
$ cc2                NA, NA
$ admin1             "CA", "TX"
$ admin2             "083", "487"
$ admin3             NA, NA
$ admin4             NA, NA
$ population         5741, 10573
$ elevation          154, 361
$ dem                152, 361
$ timezone           "America/Los_Angeles", "America/Chicago"
$ mdate              2017-03-09, 2017-03-09