Census Map: Difference between revisions
From charlesreid1
| Line 33: | Line 33: | ||
[[Image:QGIS_USCounties.png|500px]] | [[Image:QGIS_USCounties.png|500px]] | ||
Note that you can also obtain geographic information from various APIs - for example: | Note that you can also obtain geographic information from various APIs - for example, the Census Reporter API returns GeoJSON for geographic entities by ID: | ||
<pre> | <pre> | ||
Revision as of 05:48, 8 February 2015
My goal is to set up a map that connects census tract data with some other census data, e.g., population or median income.
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
Mapping County Boundaries
To map census data, I wanted to get shapefile information.
Here's shapefile information 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.
Dittos for a US counties map, it was around 70 MB and straightforward to load with a map:
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
}
}