Skip to content

Simple scripts for fetching Census places data and generating json representations

Notifications You must be signed in to change notification settings

censusreporter/census-places-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

census-places-json

Simple scripts for fetching Census places data from Name Look-up Tables and generating json representations.

NOTE: This project might still be useful if you want to manipulate data from the Census Name Look-up Tables, but not all geographies are represented in those files. You're probably better off looking into census-shapefile-utils for extracting data about Census places.

get_lookup_table_files.py

Census.gov says: "The Name Look-up Tables (NLTs) are among the geographic products that the Census Bureau provides to states and other data users containing the small area census data necessary for legislative redistricting. The NLTs contain the names and codes of every geographic area of the specific type within the state."

This script will download all the lookup table zip files available at this URL. An optional -s argument will limit the download to a single state.

>> python download_lookup_table_files.py
>> python download_lookup_table_files.py -s WA

make_json.py

After running get_lookup_table_files.py, you will probably want to generate JSON from the extracted data. An optional -s argument will limit the export to a single state, and an optional -g argument will limit the export to a single geographic type.

>> python make_json.py
>> python make_json.py -s WA
>> python make_json.py -g CDP
>> python make_json.py -s WA -g CDP

Each record in the JSON will have three attributes:

  • id: a generated key with the bits necessary for making a query against this place, e.g. "STATEFP:53|GEOTYPE:INCPLACE|PLACEFP:67000"
  • name: a human-friendly title for the Census place, e.g. "Spokane, Washington"
  • text: a machine-friendly field suitable for autocomplete matching

examples

Two example pages are included, which use the Select2 widget for autocomplete matching.

  • simple.html: Open this in your browser, and search for any city in Illinois.
  • all-places.html: To try this example, you'll need to run the python scripts in this project to download Census data and generate a places.json file, then copy it to the examples/json directory.

About

Simple scripts for fetching Census places data and generating json representations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published