Skip to contents

Geocode addresses or locations in bulk using the Mapbox Batch Geocoding API

Usage

mb_batch_geocode(
  data,
  search_column = NULL,
  address_line1 = NULL,
  address_number = NULL,
  street = NULL,
  block = NULL,
  place = NULL,
  region = NULL,
  postcode = NULL,
  locality = NULL,
  neighborhood = NULL,
  country = NULL,
  permanent = FALSE,
  limit = 1,
  search_within = NULL,
  language = NULL,
  types = NULL,
  proximity = NULL,
  worldview = NULL,
  allow_large_job = FALSE,
  access_token = NULL,
  sf = TRUE
)

Arguments

data

An input data frame

search_column

A column that contains a description of the place to geocode, or a full address. search_column cannot be used with address component arguments.

address_line1

The name of a column in data that contains the first line of an address, e.g. "1600 Pennsylvania Ave NW"

address_number

The name of a column in data that contains the address number, e.g. "1600". Not required when address_line1 is used.

street

The name of a column in data that contains the street name, e.g. "Pennsylvania Ave NW". Not required when address_line1 is used.

block

The name of a column in data that describes the block, used in some Japanese addresses.

place

The name of a column in data that contains the place name; typically a city, village, or municipality, e.g. "Washington"

region

The name of a column in data that represents sub-national administrative features, such as states in Mexico or the United States. Example: "DC"

postcode

The name of a column in data representing the postal code of the address; this will be a ZIP code in the United States, e.g. "20500"

locality

The name of a column in data that describes official sub-city locations, such as arrondissements in France.

neighborhood

The name of a column in data that represents a colloquial neighborhood name for the location.

country

A character string or vector of ISO 3166 alpha-2 country codes within which you would like to limit your search.

permanent

Either FALSE (the default) when results are not intended to be stored, or TRUE if the results are planned to be stored.

limit

How many results to return per address. This is not currently accessible for users and can only be 1.

search_within

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.

language

The user's language, which can help with interpretation of queries. Available languages are found at https://docs.mapbox.com/api/search/#language-coverage.

types

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.

proximity

proximity Either a vector of coordinates or an IP address string to bias the results to favor locations near to the input location.

worldview

Returns features intended for different regional or cultural groups. The US ('us') world view is returned by default.

allow_large_job

A boolean indicating that the user is OK with potential charges incurred to their account due to a large geocoding job (over 1000 addresses). The Mapbox Free Tier includes 100,000 free geocodes per month. Defaults to FALSE.

access_token

The Mapbox access token (required); can be set with mb_access_token()

sf

A boolean that determines whether the output will be an sf POINT object (TRUE, the default) or a regular data frame (FALSE).

Value

The input dataset as an sf POINT object representing the geocoded locations, or the input dataset with longitude, latitude, and matched address columns included.