Skip to contents

Get Coordinates/Geometries for Valid Location Keys

Usage

get_location_coords(
  location_unit_type,
  location_keys,
  version,
  token,
  large_query_chunk_size = 10,
  large_query_pause = 0,
  limit = NULL,
  verbose = TRUE
)

Arguments

location_unit_type

Either "coordinates" (for buffer around single point) or type of geographic location, including: "countries", "regions", "cities", "zips", "places", "geo_markets", "electoral_district", or "country_groups". See the Basic Targetting documentation for more information.

location_keys

Key associated with location. Use the get_fb_parameter_ids function to get location keys; see here for examples.

version

API version. e.g., "v19.0"

token

Facebook API token

large_query_chunk_size

The function will first try to query all locations using one API call. If too many locations are requested, the function will query in chunks. By default, the function will query 10 locations at a time. (Default: 10).

large_query_pause

The function will first try to query all locations using one API call. If too many locations are requested, the function will query in chunks. After each query, the large_query_pause can be set to > 0 to sleep for large_query_pause seconds in order to not make too many API calls too quickly. (Default: 0).

limit

Number of parameter IDs to search for.

verbose

If the function needs to make multiple queries to obtain location information for all location keys, print progress. (Default: TRUE).

Value

Spatial features dataframe

Examples

if (FALSE) {
#### Define version, creation act, and token
VERSION = "enter-version"
TOKEN = "enter-token"

#### Grab locations
loc_sf <- get_location_coords(location_type = "countries",
                                 location_keys = c("US", "MX", "CA"),
                                 version = VERSION,
                                 token = TOKEN)

}