An open API service indexing awesome lists of open source software.

https://github.com/jrosell/rreversegeocoder

The goal of rreversegeocoder is to, given latitude and longitude, find the nearest city.
https://github.com/jrosell/rreversegeocoder

geocoder geocoding geonames r r-geocoding-geocoder reverse-geocoding

Last synced: 7 days ago
JSON representation

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

Awesome Lists containing this project

README

          

# rreversegeocoder

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

Why? We get new features for feature engineering that can improve the
performance of machine learning models.

## Installation

You can install the development version of rreversegeocoder from
[GitHub](https://github.com/jrosell/rreversegeocoder) with:

``` r
pak::pak("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:

``` r
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