tractR provides a simple interface to interact with the U.S. Census Batch Geocoder. In particular, the U.S. Census Batch Gecoder restricts submissions to 10,000 addresses per call and requires addresses to be formatted in a particular order. tractR helps split your data into 10,000 address pieces and puts together the API call to the Geocoder.
tractR requires that your data contain the following elements: an identifier that uniquely identifies a row, street names, city, state and postal code. Let's use an example from public data.
# Load libraries for vignette library(tractR) library(httr) library(data.table) library(dplyr) library(dtplyr) library(pbapply) library(stringr)
CAMBRIDGE_URL <- 'https://data.cambridgema.gov/api/views/crnm-mw9n/rows.csv?accessType=DOWNLOAD&bom=true' assessing <- fread(CAMBRIDGE_URL, nrows = 10) assessing$id <- 1:nrow(assessing) assessing$Zip <- str_pad(assessing$Zip, 5, pad = '0') assessing <- data.table(assessing) assessing.geo <- getTracts(data = assessing, unique_id = 'id', address = 'Mailing Address', city = 'City', state = 'State', postalcode = 'Zip')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.