[GIS] Filtering zip code shapefile by state/other zip code shapefiles

censusqgisshapefiletigerzip-codes

I am looking to map one state based on zip codes (I have associated quantitative data that I am planning to join in QGIS).

I see that the Census TIGER shapefiles have an option for zip codes, but I don't see any associated state-based column that would allow for me to select a single state.

Can anyone could confirm whether it has state information, or has another source I can refer to, or does anyone have a spreadsheet that separately links zip code to state?

Best Answer

From the ZCTA brochure

ZCTAs follow census block boundaries but are independent of all other statistical and governmental entities, therefore ZCTAs frequently cross the boundaries of other geographic boundaries. In addition, ZCTAs may occasionally cross state boundaries.

That said, if you're using , you can accomplish this like this.

SELECT zcta.gid                  
FROM census.zcta
JOIN census.state AS s
  ON ST_Intersects( s.geog, zcta.geog )
WHERE s.name = 'Texas'; -- or whatever name you want.

Of course, TIGER is a beast. The Texas 2016 polygon has 58,569 points. You may want to ST_Subdivide first. I wouldn't even meaningfully try to do this in QGis. It's too much of a bear of a query.

Related Question