A question came up on the US Census slack, leading to the recognition that the US Census Bureau API
doesn't support queries for data for "all ZCTAs in a state". Nothing about the Census Bureau's definition of
ZCTA requires that they be contained within a single state, which is probably why the API rejects the query with a message,
error: unknown/unsupported geography heirarchy
.
I've been looking for a general method to answer these kinds of questions for a long time. This Gist demonstrates a workable approach. It's based on data published by the Census LEHD LODES program, which provides, for every Census block in the US, a crosswalk indicating which geographies that block is in. (The set of geographies is limited but still very useful. See the technical doc PDF for more details.)
For any two geography types, one can simply select those two columns from the crosswalk and eliminate dupli