See the Mapbox Geocoding API documentation for more information.
mb_geocode(
search_text = NULL,
structured_input = NULL,
permanent = FALSE,
autocomplete = TRUE,
limit = 1,
types = NULL,
search_within = NULL,
language = NULL,
country = NULL,
proximity = NULL,
worldview = NULL,
output = "coordinates",
access_token = NULL
)mb_reverse_geocode(
coordinates,
permanent = FALSE,
limit = 1,
language = NULL,
types = NULL,
country = NULL,
worldview = NULL,
output = "text",
access_token = NULL
)
A character vector, list, or sf
object representing the query
results.
The text to search, formatted as a character string. Can be an address, a location, or a description of a point of interest.
A named list of structured address inputs, to be used in place of search_text
when more formal address inputs are desired. Available parameters, to be used as the names of list elements, include 'address_line1', 'address_number', 'street', 'block', 'place', 'region', 'locality', 'neighborhood', and 'country'. See here for more documentation: https://docs.mapbox.com/api/search/geocoding/#forward-geocoding-with-structured-input.
Either FALSE (the default) when results are not intended to be stored, or TRUE if the results are planned to be stored.
Whether or not to return autocomplete results. Defaults to FALSE.
How many results to return; defaults to 1 (maximum 10).
A vector of feature types to limit to which the search should be
limited. Available options include 'country'
, 'region'
, 'postcode'
,
'district'
, 'place'
, 'locality'
, 'neighborhood'
, 'address'
, street
, block
, address
. and 'secondary_address'
. If left blank, all types will be searched.
An sf
object, or vector representing a bounding box of
format c(min_longitude, min_latitude, max_longitude, max_latitude)
used
to limit search results. Defaults to NULL.
The user's language, which can help with interpretation of queries. Available languages are found at https://docs.mapbox.com/api/search/#language-coverage.
A character string or vector of ISO 3166 alpha-2 country codes within which you would like to limit your search.
Either a vector of coordinates or an IP address string to bias the results to favor locations near to the input location.
Returns features intended for different regional or cultural groups. The US ('us'
) world view is returned by default.
one of "text"
(the default), which will return a character
string or list of character strings representing the returned results;
output = "sf"
, returning an sf
object; or "full"
, which will return a
list with the full API response.
The Mapbox access token (required); can be set with
mb_access_token()
The coordinates of a location in format c(longitude, latitude)
for which you'd like to return information.
if (FALSE) {
whitehouse <- mb_geocode("1600 Pennsylvania Ave, Washington DC")
}
if (FALSE) {
mb_reverse_geocode(c(77.5958768, 12.9667046), limit = 5, types = "address")
}
Run the code above in your browser using DataLab