FIPS, Shapefiles, geoJSON and Google Maps

I've been working on an app to get demographic data for census blocks within the US. Every block has a designated FIPS number associated with it. It's a 15-digit number that begins with the state identifier and ends with the block identifier.


The Temboo/DataGov API returns the FIPS code along with the demographic data. As you can tell a FIPS code is really just a geographical boundary identifier so I went looking for the corresponding geoJSON. Turns out that there aren't any free service providers for FIPS-to-geoJSON data.

The Census Bureau provides free TIGER Shape files  for the entire country, state-by-state in the form of a zipped archive of binary files. You can then install the Geospatial Data Abstraction Library (brew install gdal on a mac) which also installs a utility called ogr2ogr. You can unzip the archive and run the utility to generate a  geoJSON file from the SHP file -
ogr2ogr -f "GeoJSON" output.json input.shp
 I downloaded the data for New York state and that generated a 635MB geoJSON file. I guess I'll need to write a whole app around it and serve it out of a database on Heroku or AWS - my Cloud9 quota is already perilously close to being exhausted.

I did try it out though. This is what the geoJSON object looks like (I had to paste it into a gist as a javascript file instead of a JSON file because gist actually rendered the map for the JSON!). The FIPS code in the file below is tagged as GEOID.

The code is from my previous post about the Navel Gazing app. I just updated the mapdata model to include the polygon for the FIPS ID.

I then updated the HTML file to include the shape info.

The result  -


Comments

Popular posts from this blog

The Forecaster Brown Fan Club

How to Create a Pentaho Report Using the REST Client

Automated Testing with vncdotool (Not Headless, but Hairless)