From charlesreid1

Revision as of 05:52, 8 February 2015 by Admin (talk | contribs)

My goal is to set up a map that connects census tract data with some other census data, e.g., population or median income.

This covers some of the steps necessary to do this. It is a work in progress...

Picking an API

Census.gov API Key

I started with the SunglightLabs Census library, which provides a Python wrapper to the 2010 Census data API (wow!):

https://github.com/sunlightlabs/census

But it requires a developer key from census.gov (obtained here http://www.census.gov/developers/), which I requested, and then waited, and waited, and waited...

Census Reporter API

After giving up on waiting for a Census.gov developer key in the next day, I found the census reporter API, which allows for queries of census data in a very sensible REST format.

Detailed documentation of their API available here: https://github.com/censusreporter/census-api/blob/master/API.md

A very, very nice interface!

Mapping Census Regions

In order to accomplish the ultimate goal of mapping census data, we have to be able to first map census regions - counties, states, congressional districts, and so on. This section covers attempts to do this.

Shapefiles for U.S. Counties

I started with a shapefile defining US county boundaries.

Here is a list of shapefile information that is provided by the Census Bureau: http://www.census.gov/cgi-bin/geo/shapefiles2010/main

I started with a county map of California, tl_2010_06_county10.zip. The zip file contained a set of files, including the shapefile. I fired up QGIS to have a look at it.

QGIS CaliforniaCounties.png

Next, I loaded up a (quite large) US counties map - 70 MB total. It was straightforward to find, download, and view in QGIS:

QGIS USCounties.png

Note that you can also obtain geographic information from various APIs - for example, the Census Reporter API returns GeoJSON for geographic entities by ID:

$ curl "http://api.censusreporter.org/1.0/geo/tiger2013/04000US55?geom=true"
{
    "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [
                        -92.674543,
                        45.382868
                    ],
                    ...
                ]
            ]
        ]
    },
    "type": "Feature",
    "properties": {
        "awater": 29365986992,
        "display_name": "Wisconsin",
        "simple_name": "Wisconsin",
        "sumlevel": "040",
        "population": 5664893,
        "full_geoid": "04000US55",
        "aland": 140268861626
    }
}