Skip to content

chcrpa-gis/pullen-census-data-tools

Repository files navigation

Chattanooga-Hamilton County Regional Planning

IMPORTANT NOTICE

UPDATE: The tool appears to be working again. If issues arise, report a bug or e-mail me.

As of May 2025, the U.S. Census has made CDN changes such that the Python objects utilized by the data extraction tool can no longer connect to the Census server. Solutions are being investigated and will be implemented as time allows.

Pullen Census Data Tools

This Python toolbox is designed to work within Esri ArcGIS Pro software to provide a pleasant user experience when extracting Census data, in particular the 5-year estimates from the American Community Survey (ACS). The extracted data will either take the form of a stand alone table inside an existing file geodatabase or, if geometries were selected, as a feature class with the selected variables appended to the attribute table.

Installation

Save the toolbox (.pyt) and accompanying metadata files (.xml) to a location that can be accessed by ArcGIS Pro. Within ArcGIS Pro, right-click on Toolboxes within the Catalog pane, then Add Toolbox. Navigate to the location where the toolbox has been saved and add it to the project.

Resources

The following U.S. Census Bureau publication is an indispensible reference for American Community Survey data. Chapter 8, Calculating Measures of Error for Derived Estimates, provides guidance on how to work with margins of error.

Understanding and Using American Community Survey Data: What All Data Users Need to Know

Command Line

The tool can be run from the Python Window of ArcGIS Pro with a little work. An easy method for getting the correct syntax, including the toolbox import, is to fill out the tool interface and then, instead of clicking Run, click on the caron beside Run then Copy Python Command.

Alternate Text

Here is the result. The user should modify the paths, variables, etc. to achieve the desired result.

arcpy.ImportToolbox(r"C:\User\<user>\Documents\ArcGIS\Projects\Demo\Demo.atbx")
arcpy.PullenCensusData.ACS5Yr(
    year=2021,
    state="[47] Tennessee (TN)",
    counties="'[065] Hamilton'",
    level="Tract",
    census_variables="'[B01001_002E] SEX BY AGE Male';'[B01001_026E] SEX BY AGE Female';'[B01003_001E] TOTAL POPULATION'",
    use_alias=True,
    null_records=None,
    margin_of_error=True,
    geometries=True,
    output=r"C:\Users\<user>\Documents\ArcGIS\Projects\Demo\Demo.gdb\TN_Hamilton_Tract_2021"
)

NOTE: When using Copy Python Command, the tool import path may be to a .atbx file, typically within and having the same name as the project (.aprx) itself. The qualified path to Pullen Census Data Tools.pyt may be substituted, however.

arcpy.ImportToolbox(r"C:\Users\<user>\Documents\GitHub\pullen-census-data-tools\Pullen Census Data Tools.pyt")

Known Issues

  • Changes made by the Census have resulted in Python objects no longer working on their webpages. Investigating solutions and will update as time allows.
  • The tool is incompatible with ArcMap.
  • The tool currently only supports B Tables.

Team Members

Randolph Pullen (rpullen@chattanooga.gov)

Planning Analyst II, Research & Analysis

Chattanooga-Hamilton County Regional Planning Agency

Special thanks to Tim Kuhn, Director of the Tennessee State Data Center, for inspiring this effort and providing critical feedback while evolving from an idea to a working toolbox.

License

History

  • 2024-04-01 Added 2023 to the list of years from which to download data.
  • 2024-12-15 Explicitly imported NumPy as it was no longer recognized by default when using ArcGIS Pro 3.4.0.
  • 2024-12-08 Updated the code to reflect the deprecation of the inplace parameter from DataFrame.set_axis() in Pandas
  • 2023-06-13 Updated the code to work with changes made to the Census website.
  • 2023-04-26 Included instructions on how to run the tool from the Python Window.
  • 2023-04-24 Added the ability to select between tracts and block groups. Working to limit the variables presented in the drop down to only those available for the selected geography. Currently only supporting B tables. Addressed code negatively impacted by ArcGIS Pro 3.1 tool deprecations.
  • 2022-12-08 As the Census Bureau has now released 2021 data, that year is now an option in the year parameter drop down.
  • 2022-11-09 Fixed issues with the tool behavior such that it will now work without being re-initialized or if called from the Geoprocessing History. Modified the updateParamters method to address the issue of not all estimates being available across all years and to ensure that outputs are directed to an existing file geodatabase. Modified the runtime messages to be more informative.
  • 2022-11-03 Fixed the fatal error resulting from a field alias exceeding 255 characters. Added the option to use or not use descriptive field aliases.

About

An evolving Python toolbox containing geoprocessing tools for retrieving Census data from within ArcGIS Pro.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages