cxy_geocode: Batch Geocode Parsed Addresses

View source: R/batch.R

cxy_geocodeR Documentation

Batch Geocode Parsed Addresses

Description

Provides access to the US Census Bureau batch endpoints for locations and geographies. The function implements iteration and optional parallelization in order to geocode datasets larger than the API limit of 1,000 and more efficiently than sending 10,000 per request. It also supports multiple outputs, including (optionally, if sf is installed,) sf class objects.

Usage

cxy_geocode(
  .data,
  id = NULL,
  street,
  city = NULL,
  state = NULL,
  zip = NULL,
  return = "locations",
  benchmark = "Public_AR_Current",
  vintage = NULL,
  timeout = 30,
  parallel = 1,
  class = "dataframe",
  output = "simple"
)

Arguments

.data

data.frame containing columns with structured address data

id

Optional String - Name of column containing unique ID

street

String - Name of column containing street address

city

Optional String - Name of column containing city

state

Optional String - Name of column containing state

zip

Optional String - Name of column containing zip code

return

One of 'locations' or 'geographies' denoting returned information from the API. If you would like Census geography data, you must specify a valid vintage for your benchmark.

benchmark

Optional Census benchmark to geocode against. To obtain current valid benchmarks, use the cxy_benchmarks() function.

vintage

Optional Census vintage to geocode against. You may use the cxy_vintages() function to obtain valid vintages.

timeout

Numeric, in minutes, how long until request times out

parallel

Integer, number of cores greater than one if parallel requests are desired. All operating systems now use a SOCK cluster, and the dependencies are not longer suggested packages. Instead, they are installed by default. Note that this value may not represent more cores than the system reports are available. If it is larger, the maximum number of available cores will be used.

class

One of 'dataframe' or 'sf' denoting the output class. 'sf' will only return matched addresses.

output

One of 'simple' or 'full' denoting the returned columns. Simple returns just coordinates.

Details

Parallel requests are supported across platforms. If supported (POSIX platforms) the process is forked, otherwise a SOCK cluster is used (Windows). You may not specify more cores than the system reports are available

Value

A data.frame or sf object containing geocoded results

Examples

# load data
x <- stl_homicides[1:10,]

# geocode
cxy_geocode(x, street = 'street_address', city = 'city', state = 'state', zip = 'postal_code',
   return = 'locations', class = 'dataframe', output = 'simple')


censusxy documentation built on May 30, 2022, 9:11 a.m.