Census States
census/tiger/state holds one row for each of the 50 states, the District of Columbia,
Puerto Rico and the four Island Areas: American Samoa, Guam, the Northern Mariana Islands
and the US Virgin Islands. It has one partition per vintage year of the TIGER/Line state
file. The defs.yaml lists the vintages.
DealerDemographicsComponent reads state and region to set each dealer's
census_region.
Source
The attribute table (.dbf) of the TIGER/Line state and equivalent entity shapefile,
https://www2.census.gov/geo/tiger/TIGER<year>/STATE/tl_<year>_us_state.zip. Appendix Q of
the TIGER/Line Shapefiles Technical Documentation
gives its record layout. No API key is needed.
The zip is about 10 MB, nearly all of it the state outlines. The asset reads only the
11 KB .dbf member, with the same HTTP range requests as
census/tiger/tabblock20.
The file gives regions and divisions as codes. Table 6-4 of the
Geographic Areas Reference Manual
names them, and ai_public.sources.census.states holds those names. Puerto Rico and the
Island Areas have region code 9 and division code 0. They are in no region or
division.
Columns
| Column | Type | Meaning |
|---|---|---|
geo_id | String | 2-digit state FIPS code (STATEFP), the first two digits of a tract or block GEOID |
state | String | USPS abbreviation (STUSPS) |
name | String | State name (NAME) |
region | String | Census Bureau region (REGION): Northeast, Midwest, South or West; null for Puerto Rico and the Island Areas |
division | String | Census Bureau division (DIVISION), such as South Atlantic; null for Puerto Rico and the Island Areas |
land_area_m2, water_area_m2 | Float64 | Land and water area in square meters (ALAND, AWATER) |
latitude, longitude | Float64 | The state's internal point (INTPTLAT, INTPTLON), NAD83 |
year | Int64 | The vintage year |
_partition | String | The vintage year, the partition key |
Checks
Reading the file raises ValueError when:
- a
STATEFPis not two digits, or aSTUSPSnot two capital letters; - two rows have the same
STATEFPor the sameSTUSPS; - a
REGIONcode is neither a Table 6-4 region code nor9, or aDIVISIONcode is neither a Table 6-4 division code nor0; - a state or DC is missing, or is in no region or division;
- a row other than a state or DC is in a region or division.
Adding a vintage
- Add the year to
yearsinprojects/ai_public/src/ai_public/defs/census/state/defs.yamland materialize its partition. - Add the year to
partition_keysof thecensus/tiger/stateentry in each consuming location'sexternal/defs.yaml, so that location's spec has the producer's partitions. - Set
states_vintage_yearof eachDealerDemographicsComponentthat should read the new vintage. The component'sstatesinput reads only that partition.