geocode: GeoCodes text locations using the GeoNames API

View source: R/geocode.R

geocodeR Documentation

GeoCodes text locations using the GeoNames API

Description

Uses the location_word and Country columns of the data frame to make queries to the geonames API and geocode the locations in the dataset.

Note:

  1. The Geonames API (for free accounts) limits you to 1000 queries an hour

  2. You need a geonames username to make queries. You can learn more about that here

Usage

geocode(., n_results = 1, unwrap = FALSE, geonames_username)

Arguments

.

a data frame which has been locationized (see weed::split_locations)

n_results

number of lat/longs to get

unwrap

if true, returns lat1, lat2, lng1, lng2 etc. as different columns, otherwise one lat column and 1 lng column

geonames_username

Username for geonames API. More about getting one is in the note above.

Value

the same data frame with a lat column/columns and lng column/columns

Examples

df <- tibble::tribble(
   ~value,  ~location_word,                    ~Country,
   "mumbai region, district of seattle, sichuan province",  "mumbai","India",
   "mumbai region, district of seattle, sichuan province",  "seattle", "USA"
   )
geocode(df, n_results = 1, unwrap = TRUE, geonames_username = "rammkripa")



weed documentation built on Oct. 17, 2023, 1:06 a.m.