In my first mapping post we made a simple locator map. It let the user see all the properties in Knox County which had been quarantined for Meth-related activity during the last eight or so years. Although this type of map is often useful to quickly show the user the distribution of objects/events within a geographic area (e.g., distribution of crime, pizza shops, schools), it doesn’t provide a lot of context for the data. In this post, we will try adding context to this map in two different ways.First, we will group different instances of objects/events in our map by color coding the points. Then, we will create an overlay for our map in order to provide the user with information about the neighborhoods in which meth-related incidences occur.
Color coding points
Step 1: Get data – I will be using data from the Tennessee Meth & Pharmaceutical Task Force again. I start by using the Chrome Scraper Extension to grab the data. This time I will grab data for all meth incidents in Knox County instead of just quarantined properties.Step 2: Clean and prep data – I’ll start by prepping the addresses (just like I did in the last example). Then I’ll create a second additional column, which I will use to distinguish between quarantined and non-quarantined propertied. The quarantined properties all have a “quarantine date” associated with them. Since there only 30 quarantined properties, I’ll just go through and manual code each of the quarantined properties with a “1” in my new column. I will then code all the non-quarantined properties with a “0” in the same column. Step 3: Import to Fusion Tables – Identical to last example. Make sure the mapping is based of the “location” column, instead of the city or zip columns. Also, clean up any ambiguous data, or points Google has problems mapping.My map look pretty good right now. The user can quickly see every meth-related incident in Knox County during the last eight or so years…but I want the user to be able to quickly distinguish between quarantined and non-quarantined sites. Enter step 4.Step 4: Color coding – Ready to be shocked? Here’s how simple it is to color code the data points.
- Click the “Change feature style” button
- In the “Marker icon” tab, choose the “Buckets” tab.
- Divide in to two buckets using the “Quarantine” column.
- Click the “use this range” link
- Choose the right color for each bucket
- Click “save”
What this did was created two sets of marker icons. The first being any rows with a quarantine value between “0” and “0.9999”; the second being any rows with a value of “1” or greater. When I exit out of this dialog box my map updates and looks like this:
Creating a choropleth map
OK, I now want to lay statistical/numeric data over my map based on geographic boundaries. The numeric data I am going to use is average household income per census tract.
Census Tracts are small, relatively permanent statistical subdivisions of a county or equivalent entity that are updated by local participants prior to each decennial census as part of the Census Bureau’s Participant Statistical Areas Program.
On top of this backdrop, I am again going to place the icons representing each meth-related incident in Knox County during the last eight or so years.Step 1: Get data – This time I am going to use data from two unique locations to tell what is hopefully a deeper and more powerful story. I already have the meth data cleaned and coded how I want it. Next, I am going to need the income data. This data will come from one of the greatest websites ever created: Census Reporter. Seriously, it is amazing.Census Reporter allows me to quickly pull data from the various datasets created by the U.S. Census. Although their new interface is a bit wonky, it is still a million times better than digging through census.gov. Here is how we get the info we need:
- Explore for “median household income”
- Select the variable right variable
- Enter the location “Knox County, TN”
- Once Knox County is selected, Census Reporter will pop out one number for all of Knox County…which is not the number we want. To fix this, I need to tell Census Reporter I want to look at the census tract-level data. On the left side of the screen, there is a “Divid Knox County by…” heading. Below it is the census tract option.
- Once clicked, Census Reporter will spit out a median household income value for each census tract.
- From here all I need to do is export the data as a KML file.
Oh wait, you don’t know what a KML file is? A KML file, or Keyhole Markup Language file, is a format used to display geographic data in Google Maps. We can use a KML file to draw boundaries on a map.
Step 2: Import in to Fusion Tables – Another simple step. All I have to do is create new Fusion table and import the KML file.Step 3: Create the KML-based map – In Fusion Table, create a map based on “geometry.” Then change feature style for the fill color to a gradient based on the income variable.Once I save and close the dialog box, the map will update.Now I just need to combine to two maps. Unfortunately, the one weakness of Google Maps in Fusion Tables is I can’t simultaneously style two layers (i.e., the census tracts and the meth incident icons). But never fear, there is a super simple work around: