Spicing up our map

Screen Shot 2015-02-03 at 10.49.36 AMIn 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.

Screen Shot 2015-02-03 at 11.13.01 AM

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.

Screen Shot 2015-02-03 at 11.29.09 AM


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.

Screen Shot 2015-02-03 at 11.35.44 AM

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. Screen Shot 2015-02-03 at 12.39.41 PM

  1. Click the “Change feature style” button
  2. In the “Marker icon” tab, choose the “Buckets” tab.
  3. Divide in to two buckets using the “Quarantine” column.
  4. Click the “use this range” link
  5. Choose the right color for each bucket
  6. 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:

So simple! Now I’ll move onto my second way to add context to a map.

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:

  1. Screen Shot 2015-02-03 at 1.26.05 PMExplore for “median household income”
  2. Select the variable right variable
  3. Enter the location “Knox County, TN”
  4. 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.
  5. Once clicked, Census Reporter will spit out a median household income value for each census tract.
  6. 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.

Screen Shot 2015-02-03 at 2.04.05 PM

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:

Screen Shot 2015-02-03 at 2.08.15 PM