6 ms·
Noob Question: Anyone know an easy way to convert FIPS data (that this nytimes dataset uses) to Postal code?
by pj_mukh 7y ago
Noob Question: Anyone know an easy way to convert FIPS data (that this nytimes dataset uses) to Postal code?
- throwawayjava 7y agoproblem is somewhat ill-posed, but see https://raw.githubusercontent.com/bgruber/zip2fips/master/zip2fips.json https://raw.githubusercontent.com/bgruber/zip2fips/master/zi...
- jake-low 7y agoI don't think it's generally possible. The FIPS code just identifies the county (the first two digits are the state, e.g. 06 for California) and the final three identify a county in that state. So technically that column is redundant with the "county" and "state" columns; I suspect they've included it to make joining this dataset to other data that might use different name-formatting of counties/states easier. ZIP/postal codes are generally smaller (in the county I live in there are almost a hundred ZIP codes). I'm not sure they're even guaranteed to be entirely within one county either. We tend to think of ZIP codes as boundaries but they're actually delivery routes (which if you squint can be converted into boundaries by joining the properties that those routes serve together). You might be interested in this article: https://carto.com/blog/zip-codes-spatial-analysis/ https://carto.com/blog/zip-codes-spatial-analysis/
- llimllib 7y agozip codes span counties and also states. A few are actually in three different states. (I have suffered at the hands of zip-codes-as-geographic-entities)
- pj_mukh 7y agoRight, so a simple mapping I'd want is given a Zip Code, what is the corresponding FIPS Code.
- tomrod 7y agoPick a lat/long, and you can map between. Or find the centroid of the zip code and map accordingly. Or you might consider unions between the geometry objects. Qgis3 has a lot of great packages for this.
- xxpor 7y agoFIPS codes are only specific to the county. It'd be a one-to-many mapping (or many-to-one, depending on if it was a rural area, I guess? I'm not sure if ZIP codes ever cross county lines.)
- fragmede 7y agoit's the hardest of them all, many-to-many
- danso 7y agoIt's a good question, and unfortunately, the answer is that zipcode does not map well to other kinds of geographical regions, or to day-to-day-reality for that matter. To directly answer your question, it is not uncommon for zipcodes to span county boundaries. And there are even a handful that span more than one state: https://gis.stackexchange.com/questions/53918/determining-which-us-zipcodes-map-to-more-than-one-state-or-more-than-one-city https://gis.stackexchange.com/questions/53918/determining-wh... To the broader question of why zip codes can be lacking for geospatial analysis, here's a real-world situation: https://theconversation.com/how-zip-codes-nearly-masked-the-lead-problem-in-flint-65626 https://theconversation.com/how-zip-codes-nearly-masked-the-... Here's a more broader essay from CartoDB: https://carto.com/blog/zip-codes-spatial-analysis/ https://carto.com/blog/zip-codes-spatial-analysis/
- pj_mukh 7y agoInterestinggg. So, as mentioned by another user, I'm better off mapping Lat/Lon to FIPS. Found a census endpoint that does just that[1]! Now for an address, I can geocode it up. https://geo.fcc.gov/api/census/ https://geo.fcc.gov/api/census/
- danso 7y agoYou can do better than geocoding: use one of the county-level shapefiles from the TopoJSON project: https://github.com/topojson/us-atlas https://github.com/topojson/us-atlas At the very least, if you do just need point-level info, you can get the centroids of the county shapes.
- tomrod 7y agoIt's nontrivial. Check out ZCTA crosswalk in US census.