I’ve found a newer, simpler method to obtain Census 2020 data on cities (places) within your counties / MPO region.
It involves using the R packages (tidyverse, jsonlite, tidycensus) and the Census Bureau’s API system. I’ve been reluctant to use the Bureau’s APIs - - they seem as easy to decipher as Egyptian heiroglyphics.
I think the Census Bureau’s “API examples” are worth checking out:
https://api.census.gov/data/2020/dec/dhc/examples.html
To get places within counties, we need to find data from summary level 159. (My previous efforts used sumlev 155 and 160.)
The function “fromJSON” in the “jsonlite” R package is used to read the raw API data call into JSON format (Javascript Object Notation). The JSON object is then converted into standard R “data frames” using the function “as.data.frame(json_file)?
Here are snippets from my R script:
Load appropriate libraries into your R session
library(jsonlite)
library(tidyverse)
library(tidycensus)
Then pull data from the Census Bureau’s API, and have it “wrapped around” the “fromJSON” function.
My example pulls five variables from the 2020 Census DHS, for California, and for the Nine Counties in the SF Bay Area (001 through 097)….
temp1 <- fromJSON("https://api.census.gov/data/2020/dec/dhc?get=NAME,P1_001N,H8_001N,H3_001N,H…")
bayarea1 <- as.data.frame(temp1)
And the LAST step uses the package “tidyverse” to clean up the variable names, and creates a “joining” variable GEOID that can be used in subsequent analyses of place-level data for your region. Those data can be from the ACS or the Decennial Census. They key is having a discrete list of places with an appropriate joining variable (GEOID).
bayarea2 <- bayarea1 %>%
filter(!V1=="NAME") %>%
mutate_at(c("V2","V3","V4","V5","V6"), as.numeric) %>%
rename(place_name = V1,
totpop_2020 = V2, # P1_001N
hhpop_2020 = V3, # H8_001N
total_du_2020 = V4, # H3_001N
occ_du_2020 = V5, # H3_002N
vac_du_2020 = V6, # H3_003N
state_fips = V7,
county_fips = V8,
place_fips = V9) %>%
unite(GEOID,c("state_fips","place_fips"),sep="", remove=FALSE)
That’s it!
My initial foray into these "API calls wrapped in R functions" was to extract Census 2020 data on other “geo-within-geo” of interest:
1. Congressional Districts by County
2. Congressional Districts by Place
3. Lower State Houses by County
4. Lower State Houses by Place
5. Upper State House by County
6. Upper State House by Place
I also had to master the process of scraping data from sites like wikipedia and the Daily Kos to get data that I could merge with census data. I won’t publish details on this in the CTPP listserv, but if you’re interested in these, let me know.
My inspiration is trying to find the congressional districts, and state legislators that are in my region.If you’re an MPO, you probably want to know who’s door to be knocking on? :)
Chuck
I cross-posted this to my LinkedIn account, but this may be of interest to our regional transportation planners.
More on Census American Community Survey / San Francisco Bay Area data.
I've amended my Bay Area-specific table (attached) to include data from the 2020 ACS.
The 2020 single-year ACS data was ONLY released using experimental weights, and data were ONLY published at the US and STATE level. Still, however, the Bureau released the microdata for the 2020, with experimental weights. And those microdata for 2020 are available on the IPUMS.org <http://ipums.org/> site. Also included on IPUMS.org <http://ipums.org/> are the 2019 ACS PUMS data with experimental weights. This allows the analyst to "bridge" the ACS for "regular years" (2006 - 2019, 2021, 2022) and the "experimental weight years" (2019, 2020).
Go to the Census Bureau's web site to learn more about the 2020 ACS data and experimental weights. I don't think I can explain what they did!!
This is the first time I've examined ACS-2020-X for the Bay Area. It passes the "sniff test" and seems in line with 2019 and 2021. We need a lot more people to take closer looks at the ACS PUMS data for these past few years.
The 2022 PUMS data will be released next month, October 2023. My guess is that the great people at IPUMS will have the new 2022 data up and running by December of this year.
Chuck

Hey Mike:
Yes, I’ve just uploaded my scripts to the 2006-2022 USA + States + Places + Counties; and my new script for SF Bay Area counties. The Bay Area script may be useful if you’re focusing in on counties in your region.
https://github.com/chuckpurvis/r_scripts/blob/main/ACS_AllYears_jtw_bayarea…https://github.com/chuckpurvis/r_scripts/blob/main/ACS_AllYears_jtw_add2022…
The data for 2020 is pulled from Census Bureau’s published tables on the 2020-Experimental Data
2020-Experimental data at the state and LARGE county-level is available, but you’d need to use the 2020 Experimental PUMS, via IPUMS. I think I may do that later today, after my beer break.
Chuck
> On Sep 15, 2023, at 6:22 AM, Mike Bruff <mike.bruff(a)campo-nc.us> wrote:
>
> Hi,
> Would you share your R script that produced the tables below.
> Thank you,
> Mike
>
> Mike Bruff
> Transportation Modeling Engineer
> Capital Area MPO
> 1 Fenton Main Street, Suite 201
> Cary, NC 27511
> 984-542-3601 (main)
> 984-542-3613 (direct)
> campo-nc.us <https://www.campo-nc.us/>
> mike.bruff(a)campo-nc.us <mailto:mike.bruff@campo-nc.us>
>
>
> From: Charles Purvis <clpurvis(a)att.net <mailto:clpurvis@att.net>>
> Sent: Thursday, September 14, 2023 4:33 PM
> To: The Census Transportation Products Program Community of Practice/Users discussion and news list <ctpp(a)listserv.transportation.org <mailto:ctpp@listserv.transportation.org>>
> Subject: [CTPP News] New ACS data for 2022, single year estimates
>
> Today the Census Bureau released the 2022 single year estimates from the American Community Survey.
>
> I updated my last year’s (r package tidycensus) script to pull 2006-2021 single year ACS data, for 2022. If you’re an R / tidycensus user, be sure to follow Dr Kyle Walker on twitter. He’s totally on top of new census products, including the DHC-A product to be released next Thursday.
>
> New data from the Census Bureau shows a 32 percent increase in national transit commuting, 2022 over 2021; and a 12 percent decrease in national at-home workers. The 160.6 million US workers is a historical high.
>
> The rebound in US transit commuting is encouraging.
>

> _______________________________________________
> CTPP mailing list -- ctpp(a)listserv.transportation.org <mailto:ctpp@listserv.transportation.org>
> To unsubscribe send an email to ctpp-leave(a)listserv.transportation.org <mailto:ctpp-leave@listserv.transportation.org>
Today the Census Bureau released the 2022 single year estimates from the American Community Survey.
I updated my last year’s (r package tidycensus) script to pull 2006-2021 single year ACS data, for 2022. If you’re an R / tidycensus user, be sure to follow Dr Kyle Walker on twitter. He’s totally on top of new census products, including the DHC-A product to be released next Thursday.
New data from the Census Bureau shows a 32 percent increase in national transit commuting, 2022 over 2021; and a 12 percent decrease in national at-home workers. The 160.6 million US workers is a historical high.
The rebound in US transit commuting is encouraging.