geocode_mapbox: Geocode a location using the mapbox geocode API.

Description Usage Arguments Value Examples

View source: R/geoCode_mapbox.R

Description

The function geocodes a single address given as a character string. Be as specific as possible, including the country or postcode to avoid ambiguity. To avoid loss of accuracy when geocoding a lat/lng string, the geoCode function does not geocode lat/lng strings but instead returns the same string as a dataframe.

Usage

1
2
3
4
5
geocode_mapbox(
  address,
  api_key = Sys.getenv("mapbox_api_key"),
  return_all = TRUE
)

Arguments

address

character string with address to be geocoded. Be as specific as possible to avoid ambiguity.

api_key

character string containing api key for the google maps geocode api. You can generate one for free in your google cloud console.

return_all

logical value. Some locations may return more than one geocoded result. If you only want one row returned set return_all = FALSE.

Value

a data.frame containing the coordinates, location type and approximate address.

Examples

1
2
3
4
geocode_mapbox('London Bridge, London, UK', return_all = FALSE)

#  lat        lng             type                           address
#  51.50788 -0.0877321 GEOMETRIC_CENTER London Bridge, London SE1 9RA, UK

Chrisjb/RDistanceMatrix documentation built on Jan. 27, 2021, 9:12 p.m.