censusxy package is designed to provide easy access to the U.S.
Census Bureau Geocoding
has also been developed specifically with large data sets in mind - only
unique addresses are passed to the API for geocoding. If a data set
exceeds 1,000 unique addresses, it will be automatically subset into
appropriately sized API calls, geocoded, and then put back together so
that a single object is returned. There is also support for parallel
processing of requests, which can significantly shorten the time it
takes to batch geocode large numbers of addresses.
censusxy is described in a 2021 paper in Transactions in
Chris and Branson - please cite the paper if you use
censusxy in your
censusxynow supports parallel processing on Windows (macOS and Linux had support for this since
v1.0.0), thanks to a PR from Christopher Kenny, and an error that cropped up with macOS 12.4 when submitting requests for parallel processing is addressed
Rversion 3.4 is now the minimum version supported
The easiest way to get
censusxy is to install it from CRAN:
Alternatively, the development version of
censusxy can be accessed
from GitHub with
# install.packages("remotes") remotes::install_github("chris-prener/censusxy")
Since the package does not need
sf for its basic functionality, it is
a suggested dependency rather than a required one. However, many users
will want to map these data as
sf objects, and we therefore recommend
sf. Windows and macOS users should be able to install
sf without significant issues unless they are building from source.
Linux users will need to install several open source spatial libraries
sf itself up and running.
If you want to use these
sf, you can either install it individually
(faster) or install all of the suggested dependencies at once (slower,
will also give you a number of other packages you may or may not want):
## install sf only install.packages("sf") ## install all suggested dependencies install.packages("censusxy", dependencies = TRUE)
censusxy package contains two data sets,
stl_homicides (n =
stl_homicides_small (n = 24), that can be used to
demonstrate the functionality of the package. The
data is included specifically for quick experimentation, as its small
sample size ensures an expedient response from the API.
censusxy’s functionality, load the package and either of the
sample data sets:
library(censusxy) data <- stl_homicides
There are two possible variable configurations (
specified using the
output argument), and two possible output class
sf, specified using the
homicide_sf <- cxy_geocode(data, street = "street_address", city = "city", state = "state", output = "simple", class = "sf")
If you request an
sf object, you easily preview the results with the
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.