<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Carl V. Lewis</title>
	<atom:link href="http://carlvlewis.net/?feed=tumblog" rel="self" type="application/rss+xml" />
	<link>http://carlvlewis.net</link>
	<description>Web developer, digital journalist, M.Sc. candidate at Columbia University Graduate School of Journalism</description>
	<lastBuildDate>Tue, 13 Nov 2012 01:49:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
			           	
    	    	<item>
			<title>Tutorial: Building a hover-enabled map using Tilemill</title>
			<link>http://carlvlewis.net/?p=3030</link>
			<comments>http://carlvlewis.net/?p=3030#comments</comments>
			<pubDate>Thu, 02 Aug 2012 05:05:48 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Visualization]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=3030</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p>In this tutorial, we'll create an interactive, chloropleth map of census data, complete with hover tooltips and an HTML legend. We'll use QGis and Google spreadsheets to prepare the data, Tilemill to style the map tiles and MapBox for hassle-free hosting. You'll need to be running Mac OS X to follow along.<p><a href="http://carlvlewis.net/?p=3030#comments" title="Comment on Tutorial: Building a hover-enabled map using Tilemill">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p><p><em>This is the first of two tutorials on adding hover interactions to interactive maps<em> using free, open-source tools.</em></em></p>
<p>Today I wanted to break down the step-by-step process of how I created <a href="http://carlvlewis.net/?portfolio=interactive-statewide-population-change-between-2010-and-2011">this interactive, chloropleth map</a> of Georgia population change from 2010 to 2011. While today&#8217;s tutorial doesn&#8217;t cover how to add hover states or moving tooltips to your maps, such as those you see in <a href="http://carlvlewis.net/cartodbleaflet/examples/statewidepop.html">this iteration</a> of the same map made using <a href="https://github.com/Vizzuality/cartodb-leaflet">CartoDB+Leaflet</a>, I&#8217;ll cover how to add those more advanced features in a later post (they require using a few more tools and doing a bit more programming). For now, though, we&#8217;re going to stick to the basics of simple hover interactions. Here&#8217;s what you&#8217;ll need to follow along:</p>
<ul>
<li>Mac OS X</li>
<li><a href="http://www.qgis.org/">QGis</a> (free)</li>
<li><a href="http://tilemill.com">Tilemill</a> (free)</li>
<li>A free <a href="http://mapbox.com">MapBox</a> account where you will host your MBTiles</li>
<li><a href="http://docs.google.com">Google spreadsheets</a> (or Microsoft Excel, if you&#8217;re more comfortable with that)</li>
</ul>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">1. Gathering and preparing the data</span>
<p>The first thing you&#8217;ll need to do is locate your data and parse it down to a format in which it can be easily visualized. For this example, we&#8217;re using population estimates from the U.S. Census Bureau, which, luckily for us, has already done most of the heavy lifting analysis-wise. Download the data for Georgia or whatever other state you wish to visualize as a comma separated value (.csv) file from <a href="http://www.census.gov/popest/data/counties/totals/2011/CO-EST2011-03.html">this page</a>. Now you&#8217;ll want to turn that .csv file into a Google spreadsheet. You can do this from the Google Drive dashboard by selecting Create&gt;Spreadsheet, then choosing File&gt;Import once your new spreadsheet opens. Locate and upload the .csv file. Select &#8220;Replace current spreadsheet&#8221; and set &#8220;Comma&#8221; as the separator character. Voila. Your data should then appear for each county. Here&#8217;s what the correct options for that will look like:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-07-at-6.55.50-PM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-07-at-6.55.50-PM.png" alt="" title="Screen Shot 2012-08-07 at 6.55.50 PM" width="600" height="450" class="aligncenter size-full wp-image-3098" /></a></p>
<p>Given that each county has a different base population, the only standar way to compare en masse how many residents each county gained or lost is by calculating the percent change (see <a href="http://www.mathgoodies.com/lessons/percent/change.html">here</a> to figure out how to calculate that in Excel or Google Spreadsheets). In this example, however, the Census Bureau has already calculated out the percent change for us, making our job that much easier. Delete all the unnecessary columns from the spreadsheet, leaving only the county name in the first column, the 2010 and 2011 population totals in the second and third columns, and the &#8220;Percent&#8221; value in the fourth column (the &#8220;Percent&#8221; value refers to the percent change between the two years). Also make sure to delete any extra rows at the top or bottom of the spreadsheet, so that the first row contains the column titles, with the first county beginning on the second row and ending on the last row. Highlight the column containing the county names and select “Data>Sort sheet by column, A-Z.&#8221; This will put the entries in alphabetical order.</p>
<p>If you happen to get a weird period (&#8216;.&#8217;) preceding each county name as I did, you can get rid of it pretty easily by performing the following steps:</p>
<ol>
<li>Insert a new column to the right and, assuming your first county name begins in cell A2, enter the following formula into B2: <em>=MID(A2,2,LEN(A2))</em>. This function deletes the first character of the county name –– the unwanted period –– automatically.</li>
<li>Copy and paste the new B2 cell into the rest of the rows to apply the same formula throughout the entire spreadsheet.</li>
<li>Copy the new period-free column you just created and paste it as unformatted text into another new column to the right by selecting &#8220;Paste special&gt;Paste values only.&#8221; This formats the data in new column as values only so that it they won&#8217;t include a formula that depends on the incorrectly formatted column to work.</li>
<li>Delete the first two columns so that the first column now becomes the county names only, free of the preceding periods.</li>
</ol>
<p>We&#8217;re almost finished getting the data ready. All we have left to do is add in a column containing the official county codes for each county so that we&#8217;ll have a common attribute with which we can merge the spreadsheet with the geometric data later. Download <a href="http://www.census.gov/popest/data/counties/totals/2011/files/CO-EST2011-Alldata.csv">this .csv</a> from the Census Bureau, which contains the county codes for all 50 states. Open it as a Google spreadsheet and delete all the rows except for the ones for the state you&#8217;re visualizing. With only the rows for the state at hand remaining, highlight the &#8220;ctyname&#8221; column and select &#8220;Data&gt;Sort values from A-Z.&#8221; This should reorder the spreadsheet to be exactly the same alphabetic order as the spreadsheet with the population totals. Copy the &#8220;county&#8221; column containing the numeric county codes, which should now also be arranged in numeric order, and paste it into a new column in the spreadsheet with the population totals, which should also be sorted alphabetically. This should now give you the correct county codes for each county in a new column. Title that column simply &#8220;COUNTY&#8221; (all-caps). For an idea of what things should look like at this point, check out my Google spreadsheet <a href="https://docs.google.com/spreadsheet/ccc?key=0Au4D8Alccn4xdGpUTGQwZUNUMnR4MUtRY2FNS0pBaEE">here</a>, or see the following screenshot:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-1.41.32-AM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-1.41.32-AM.png" alt="" title="Screen Shot 2012-08-06 at 1.41.32 AM" width="589" height="495" class="aligncenter size-full wp-image-3091" /></a></p>
<p>One last thing to keep in mind: If your county codes include values less than three digits, which they probably will, make sure any values less than three-digits long have 0s preceding them to force them to be three digits long (i.e. &#8217;001&#8242;). That way, it will match up with the three digit values in the geometric data later on in the process.</p>
<p>Now that we have our population data ready, let&#8217;s download the corresponding geometric county polygons from the Census Bureau <a href="http://www.census.gov/geo/www/cob/co2000.html">here</a>. For this tutorial we&#8217;ll be using the shapefiles (.shp) format, so make sure to select the shp.zip option on the download page. I obviously used Georgia in this example; feel free to choose whatever other state you desire, so long as you follow the exact same instructions. Unzip the archive to your computer. You should see three files in the new unzipped folder: a .dbf, a .shp and a .shx. All we&#8217;ll be need for this tutorial is the .shp file.</p>
<p>At this point, you should have <strong>two different files</strong>: a Google spreadsheet of data formatted something like <a href="https://docs.google.com/spreadsheet/ccc?key=0Au4D8Alccn4xdGpUTGQwZUNUMnR4MUtRY2FNS0pBaEE">this</a>, and a shapefile of corresponding county polygons. The next step will be to take the population data and bind it to the shapefile so that the two match up.</p>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">2. Binding the data to the shapefile using QGis</span>
<p>Fire up QGis. Select the &#8220;Add Vector Layer&#8221; option from the top of the window and locate the .shp file you downloaded earlier. Open it in QGis and you should see a nice outline of your state that looks something like this:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.20.45-PM.png"><img class="wp-image-3058 aligncenter" title="Screen Shot 2012-08-05 at 10.20.45 PM" src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.20.45-PM.png" alt="" width="526" height="350" /></a>Now go back to your newly created Google spreadsheet and export the data as a .csv by selecting &#8220;File&gt;Download data as.&#8221; After downloading the .csv, rename it to something simple like &#8220;georgia.csv.&#8221; The next thing we need to do is import the .csv into QGis. But before we can do that, we need to create a new &#8216;.csvt&#8217; file by the same name and in the same directory as the .csv that will tell QGis what type of data each column is (string, number, real, etc.). For this example, your &#8216;.csvt&#8217; file will look something <a href="https://docs.google.com/open?id=0B-4D8Alccn4xbnVVU2JyX3l1S0E">like this</a>, with a data type defining each column of the .csv:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.39.32-PM.png"><img class="wp-image-3061 aligncenter" title="Screen Shot 2012-08-05 at 10.39.32 PM" src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.39.32-PM.png" alt="" width="611" height="454" /></a></p>
<p>If you&#8217;re having trouble with this part, download my .csvt <a href="https://docs.google.com/open?id=0B-4D8Alccn4xbnVVU2JyX3l1S0E">here</a>. Should you need to adjust the data types, just force open it in TextEdit and change them. The main two things to make sure is that the COUNTY column is defined as a string and the PERCENT column is defined as a value.</p>
<p>Once your .csvt file has been placed in the same directory as your .csv, go back to QGis and add a new vector layer just as you did before with the shapefile. This time, locate the .csv file and open it. QGis should then automatically detect the .csvt file in the background and assign the appropriate data types to each column in the .csv. To make sure this worked correctly, you can control-click the new .csv vector layer and select &#8220;Properties&gt;Fields&#8221; to check that each field has the appropriate data type.</p>
<p>Now you can get down to the business of binding the data from the .csv to the shapefile. Select the shapefile layer and go to &#8220;Properties&gt;Joins.&#8221; Add a new vector join, setting the .csv as the join layer and both the join field and the target field as COUNTY, like this:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.57.51-PM.png"><img class="wp-image-3062 aligncenter" title="Screen Shot 2012-08-05 at 10.57.51 PM" src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-10.57.51-PM.png" alt="" width="532" height="355" /></a></p>
<p>Applying the join should merge your spreadsheet and shapefile, binding the population data to the polygons using the shared &#8220;COUNTY&#8221;attribute that contains the matching county codes. To check and make sure everything worked correctly, control-click the shapefile vector layer in QGis and select &#8220;Open attribute table.&#8221; You should see the population data attached as columns to the end of the attribute table.</p>
<p>Once you&#8217;ve ensured that the data has been attached to the polygon vector layer, you can now export the new shapefile by control-clicking the shapefile vector layer, selecting &#8220;Save as,&#8221; and saving the layer in the ESRI Shapefile format. Now you&#8217;re ready to compress the shapefile package into a .zip and import it into Tilemill. where you can style it, add interactivity and more.</p>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">3. Styling the map in Tilemill</span>
<div> Open <a href="http://tilemill.com">Tilemill</a>. Create a new project. Under the layers panel, add a new layer and locate the .zip of the ESRI shapefile you just exported from QGis. Upload the package. Upon doing so, you should immediately see the polygons for your state. Now you&#8217;ll need to style the map in the style.mss panel using the Carto language. Because the numbers at hand for this map represent either a positive or a negative percent change, it makes sense to create a chloropleth map where red represents negative values and green represents positive values. You might try using <a href="http://colorbrewer2.org">ColorBrewer</a> or <a href="http://0to255.com">0to255</a> to find the right color ramp for your data. For this example, I used the following style parameters:</div>
<div></div>
<div></div>
<p>&nbsp;</p>
<pre name="code" class="css">
#georgia {
  line-color:#565A5D;
  line-width:0.5;
  polygon-opacity:1;
  polygon-fill:#ae8;
}

#georgia[PERCENT<=5.5] {
   polygon-fill:#558740
}
#georgia[PERCENT<=4] {
   polygon-fill:#609948
}
#georgia[PERCENT<=3] {
   polygon-fill:#6BAA50
}
#georgia[PERCENT<=2] {
   polygon-fill:#7DB863
}
#georgia[PERCENT<=1.5] {
   polygon-fill:#9FBA80
}
#georgia[PERCENT<=0.75] {
   polygon-fill:#B8CCA1
}
#georgia[PERCENT<=0.3] {
   polygon-fill:#D9DCC4
}
#georgia[PERCENT<=0] {
   polygon-fill:#F4E5E0
}
#georgia[PERCENT<=-0.5] {
   polygon-fill:#E6C5BB
}
#georgia[PERCENT<=-1] {
   polygon-fill:#D8A696
}
#georgia[PERCENT<=-1.75] {
   polygon-fill:#CC8472
}
#georgia[PERCENT<=-2.5] {
   polygon-fill:#BC5942
}
#georgia[PERCENT<=-3.9] {
   polygon-fill:#B34027
}
#georgia[PERCENT<=-5] {
   polygon-fill:#A1280F
}
</pre>
<p>As you can see, the first set of paramaters defines the style attributes of the entire polygon, including the line width and the opacity of the #georgia layer. The following sets of paramaters all set the fill color of individual &#8216;buckets,&#8217; sorted by the value of the PERCENT field. </p>
<p>Now, add layers for the surrounding geographical and cultural features, including roads, populated places, rivers, and surrounding states. When selecting the file source for your new layer, click &#8220;Browse>MapBox&#8221; to add predefined features from MapBox. Use the same method to style those layers as you did with the primary shapefile layer, pressing Command + S to save the map and refresh the view. Here&#8217;s what my styled map ended up looking like:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-11.31.40-PM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-05-at-11.31.40-PM.png" alt="" title="Screen Shot 2012-08-05 at 11.31.40 PM" width="528" height="312" class="aligncenter size-full wp-image-3066" /></a></p>
<p><span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">4. Adding the mouseover tooltips</span><br />
In Tilemill, navigate to the Templates panel. Select &#8220;Teaser.&#8221; This is the field that defines what appears in the tooltip that appears when the user moves the mouse over each polygon. Basically, all you have to do is format the field to correspond to the values in your data.</p>
<p>Here&#8217;s the formatting I used:</p>
<pre name="code" class="html">
<b>{{{CountyName}}}</b>
<div>Percent Population Change, 2010-2011:
{{{PERCENT}}}%</div>
<hr /><div>2010 Population:
{{{2010}}}</div>
<div>2011 Population:
{{{2011}}}</div>
</pre>
<p>That produced the following tooltip:<br />
<a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.32.36-AM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.32.36-AM.png" alt="" title="Screen Shot 2012-08-06 at 12.32.36 AM" width="318" height="127" class="aligncenter size-full wp-image-3071" /></a></p>
<p>As you can see, I used simple HTML markup, including the bold and horizontal line tags to add style elements. Each instance of {{{TEXTHERE}}} corresponds to a column name from the shapefile, and calls it up in the tooltip. So, to call up the percent change, I typed {{{PERCENT}}}, which refers to the PERCENT column from our data. Upon saving this, you&#8217;ll see that the tooltip appears however you format it. The possibilities here really abound.</p>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">5. Adding a legend</span>
<p>You can add a custom legend to map in much the same way. While you&#8217;re still in the Templates panel, select &#8220;Legend.&#8221; This allows you to use basic HTML/CSS both to define the structure and style of your legend, as well as the position of both the legend and the tooltip. Here&#8217;s a look at how I formatted the &#8220;Legend&#8221; field to produce my map:</p>
<pre name="code" class="html">
<div class='my-legend'>
<div class='legend-title'>Estimated Population Change, 2010-2011</div>
<div class='legend-scale'>
  <ul class='legend-labels'>
    <li><span style='background:#A1280F;'></span><-5%</li>
    <li><span style='background:#B34027;'></span>-5--4%</li>
    <li><span style='background:#BC5942;'></span>-4--3%</li>
    <li><span style='background:#cc8472;'></span>-3--2%</li>
    <li><span style='background:#D8A696;'></span>-2--1%</li>
   <li><span style='background:#e6c5bb;'></span>-1--0.5%</li>
   <li><span style='background:#f4e5e0;'></span>-0.5-0%</li>
   <li><span style='background:#D9DCC4;'></span>0-0.3%</li>
   <li><span style='background:#B8CCA1;'></span>0.3-0.8%</li>
   <li><span style='background:#9FBA80;'></span>0.8-1.5%</li>
   <li><span style='background:#7DB863;'></span>1.5-2%</li>
   <li><span style='background:#6AA84F;'></span>2-3%</li>
   <li><span style='background:#609948;'></span>3-4.5%</li>   
<li><span style='background:#558740;'></span>>4.5%</li>

  </ul>
</div>
<div class='legend-source'>Source: <a href="http://www.census.gov/popest/">U.S. Census Bureau, 5/17/2012.</a></div>
</div>
<style type='text/css'>
  .wax-legend {
    text-align: left;
    font-size: 100%;
margin-bottom:540px;
    }

.legend-title{
    text-align: left;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 90%;
    

    }
  .wax-legend .legend-scale ul {
    margin: 0;
    padding: 0;
    float: left;
    list-style: none;
    }
  .wax-legend .legend-scale ul li {
    display: block;
    float: left;
    width: 40px;
    margin-bottom: 6px;
    text-align: center;
    font-size: 70%;
    list-style: none;
    }
  .wax-legend ul.legend-labels li span {
    display: block;
    float: left;
    height: 15px;
    width: 40px;
    }
  .wax-legend .legend-source {
    font-size: 70%;
    color: #999;
    clear: both;
    }
  .wax-legend a {
    color: #777;
    }
  .wax-tooltip {
   width: 285px;
   opacity: 1;
   margin-top: 150px;
}
</style>
</pre>
<p>If you know rudimentary HTML/CSS, it&#8217;s pretty easy to tell what&#8217;s going on above. The background attribute corresponds to the color ramp I defined earlier in the style.mss field of Tilemill, and the HTML sets up the structure of the legend. After the HTML, I set some basic CSS styles, including the positioning of the legend and tooltips using the &#8220;margin&#8221; attribute and the font-size of the legend text. Save all that, and here&#8217;s a glimpse of what you get:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.49.58-AM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.49.58-AM.png" alt="" title="Screen Shot 2012-08-06 at 12.49.58 AM" width="599" height="699" class="aligncenter size-full wp-image-3078" /></a></p>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">6. Exporting your map as MBTiles</span>
<p>After you have the map styled to your liking in Tilemill, it&#8217;s a fairly straightforward process to get the map on the Web. First, in the top right of Tilemill, select &#8220;Export&#8221; and choose &#8220;MBTiles.&#8221; This is the format for the tiles that you&#8217;ll need to host the map on MapBox. Once the export panel appears, set the starting center point (for my map, it was -83.562,32.9349,6), as well as the bounds. Keep in mind that the smaller the bounds, the less tiles your map needs to render and, thus, the faster it will load. Only include the bounds you need in the map so as to minimize load time. Give the map a name, a brief description, and be sure to attribute the data source. Once you&#8217;re finished, click &#8220;Export&#8221; and save your map in the directory of your choice. The resulting .MBTiles file will now go directly into MapBox, where your map will be hosted.</p>
<span class="shortcode-typography" style="font-family: &#039;PT Sans Narrow&#039;; font-size: 20px; color: #000000;">7. Uploading your map to MapBox</span>
<p>The final step in making your map viewable by the world involves uploading the .MBTiles file you just exported to MapBox. Create a MapBox account and select the option to upload a new map. Locate your .MBTiles file and upload it to MapBox. Once it&#8217;s finshed you&#8217;ll see a preview of the map that looks like this:</p>
<p><a href="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.59.06-AM.png"><img src="http://carlvlewis.net/wp-content/uploads/2012/08/Screen-Shot-2012-08-06-at-12.59.06-AM.png" alt="" title="Screen Shot 2012-08-06 at 12.59.06 AM" width="515" height="393" class="aligncenter size-full wp-image-3080" /></a></p>
<p>Enable the &#8220;Map Details&#8221; view. Set the map to &#8220;Public,&#8221; and make sure the Zoom, Legend, Scroll zoom and Tooltip options are selected. Deselect the &#8220;Share links&#8221; option. Then click embed, and copy the embed code to use the map wherever you please.</p>
<p>Just to give you a live view of how the finished map looks and behaves:</p>
<p><iframe width='600' height='700' frameBorder='0' src='http://a.tiles.mapbox.com/v3/carlvlewis.315301.html#7/33.514/-82.573'></iframe></p>
<p>And there you go. Using Tilemill to create hover-enabled maps is easy and flexible, but it has its limitations. Because the program renders data using the UTF grid-system, it doesn&#8217;t send vector data to your browser, meaning you can&#8217;t use JavaScript or CSS3 to spice things up. The next step? Adding hover states and moving tooltips to create maps like <a href="http://carlvlewis.net/cartodbleaflet/examples/countiesbytsplost.html">this</a> for polygons and <a href="http://carlvlewis.net/cartodbleaflet/examples/nycIEP.html">this</a> for markers. Until then, feel free to ask any questions or point out any problems you may run into. Happy mapping!</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=3030#comments" title="Comment on Tutorial: Building a hover-enabled map using Tilemill">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=3030</wfw:commentRss>
			<slash:comments>8</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>What we can learn about charts from The WSJ Guide to Information Graphics</title>
			<link>http://carlvlewis.net/?p=2500</link>
			<comments>http://carlvlewis.net/?p=2500#comments</comments>
			<pubDate>Sat, 14 Jul 2012 01:16:38 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
		<category><![CDATA[bubbletree]]></category>
		<category><![CDATA[data viz]]></category>
		<category><![CDATA[hierarchical data]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2500</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>Although geared primarily toward the production of static graphics for print publications, Dona M. Wong&#8217;s The Wall Street Journal Guide to Information Graphics (2010) provides a wealth of salient and time-honored tips and guidelines that any student of data visualization would be well-advised to follow. At the heart of Wong&#8217;s book is the notion that data integrity [...]<p><a href="http://carlvlewis.net/?p=2500#respond" title="Comment on What we can learn about charts from The WSJ Guide to Information Graphics">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><p>Although geared primarily toward the production of static graphics for print publications, Dona M. Wong&#8217;s <em><a href="http://www.amazon.com/Street-Journal-Guide-Information-Graphics/dp/0393072959">The Wall Street Journal Guide to Information Graphics</a> (</em>2010<em>) </em>provides a wealth of salient and time-honored tips and guidelines that any student of data visualization would be well-advised to follow. At the heart of Wong&#8217;s book is the notion that data integrity trumps all else, and no matter how aesthetically pleasing or visually powerful an information graphic may be, if it doesn&#8217;t communicate clear and accurate data to the reader/user, it doesn&#8217;t do its job.</p>
<p>In the first two chapters of The WSJ Guide, <a href="http://donawong.com">Wong</a>, a former student of data viz extraordinaire <a href="http://edwardtufte.com">Edward Tufte</a>, addresses the topic of charting. From a theoretical standpoint, Wong lays out four principle steps to the charting process:</p>
<ol>
<li><strong>Research: </strong>Find your data source, and ensure that it&#8217;s timely, authoritative and free of bias.</li>
<li><strong>Edit: </strong> Figure out what the data says (essentially, determine what your story is), and conceive of how best to boil that data down in a way that&#8217;s simple enough for your intended audience to understand without skewing its meaning.</li>
<li><strong>Plot: </strong>Determine the appropriate chart type for your data (e.g. bar, column, line, pie, stacked bar, etc.), choose the right settings (scale, increments, axes, etc.), labeling the chart (e.g. legends and source lines) and pick the best color and typography combinations to accentuate your key message.</li>
<li><strong>Review: </strong>When you&#8217;re done, ask yourself the following questions: Does the data match up with what external sources say? Are there any outliers? Does the chart make sense? What would the average user/reader think upon first seeing the chart?</li>
</ol>
<p>Regarding the finer points of charting, Wong does an excellent job at pointing out the various dos and don&#8217;ts of the presentation process.  She sets forth clear guidelines about when to use what type of chart. For example, when dealing with change over time, Wong says to always use a line chart instead of a bar chart, as bar charts should ideally be reserved for comparing several different series of data. Also, Wong asserts, pie charts usually aren&#8217;t as good of a choice for displaying complex data as bar or line charts, primarily because they make it harder to discern discrete differences in size (later, she flat-out dismisses the donut pie chart for the same reason). A few of her other tips I found particularly relevant included: (a) avoiding high-contrast color schemes that draw attention away from the data, (b) shying away from icons with high detail so as to avoid visual overload, (c) never, under any circumstances, add cloying shadow or 3D-effects and (d) never rely on zebra patterns, dotted lines or other fancy methods of labeling. &#8220;A chart is not a piece of fine art,&#8221; Wong says.</p>
<p>Most importantly, Wong sets forth some other general principles to help designers avoid creating misleading charts. For example, when creating a bubble chart, always plot the bubbles by area, not radi. Also, never plot two different data series on noncomparable scales, and when creating bar charts, <em>always</em> start at the zero baseline. Other steps to ensuring data integrity include putting numbers into their appropriate context (comparing apples to apples), holding off on rounding until the end of the data analysis process and avoiding charting predictive numbers alongside actual ones. As Wong so eloquently puts it, &#8220;Unlike a misspelled word in a story, one wrong number discredits a whole chart.&#8221;</p>
<p>Although the new addition of interactivity to chart design adds another layer of complexity to the visualization process that Wong doesn&#8217;t address here, most of the guidelines she sets forth hold true in both static and dynamic mediums. Yet it would be interesting to hear what she has to say about the vexing question of when and when not to add static labels to interactive charts&#8230;</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2500#respond" title="Comment on What we can learn about charts from The WSJ Guide to Information Graphics">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2500</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Making the case for hover interactions in maps</title>
			<link>http://carlvlewis.net/?p=2984</link>
			<comments>http://carlvlewis.net/?p=2984#comments</comments>
			<pubDate>Fri, 13 Jul 2012 06:38:34 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[chloropleth]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[mapbox]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[mouseover]]></category>
		<category><![CDATA[QGis]]></category>
		<category><![CDATA[tilemill]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2984</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p>In keeping with my recent spate of mapping nerdiness, I decided to take an interactive map I produced last month displaying statewide annual population changes a step further by adding mouseover/hover capabilities. Here&#8217;s the hover-y, nicely-colored chloropleth map I came up with. But before I get into the nitty-gritty of how I created the map [...]<p><a href="http://carlvlewis.net/?p=2984#comments" title="Comment on Making the case for hover interactions in maps">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p><p>In keeping with my recent spate of mapping nerdiness, I decided to take an <a href="http://carlvlewis.net/?p=2742">interactive map</a> I produced last month displaying statewide annual population changes a step further by adding mouseover/hover capabilities. Here&#8217;s the <a href="http://carlvlewis.net/?portfolio=interactive-statewide-population-change-between-2010-and-2011">hover-y, nicely-colored chloropleth map</a> I came up with. But before I get into the nitty-gritty of how I created the map –– which I&#8217;ll explain step-by-step in a later post –– let me exercise a bit of self-indulgence by defending my growing belief in the need for hover capabilities when visualizing geographic data.</p>
<p>Not too long ago, I was an avid believer in the <a href="http://blog.apps.chicagotribune.com/2011/03/08/making-maps-1/">no-frills, less-interactivity-is-more approach</a> to mapping geographic data, espoused by the brilliant Brian Boyer (<a href="http://twitter.com/brianboyer">@brianboyer)</a>, News Applications Editor for NPR and a former member of the <a href="http://www.facebook.com/tribapps">News Apps Team</a> at <em>The Chicago Tribune</em>. Boyer&#8217;s <a href="http://blog.apps.chicagotribune.com/2011/03/08/making-maps-1/">argument</a> for the need to keep maps simple –– like they used to be back in the days of ink and paper –– certainly has its merits. After all, the process of bringing a physical map closer to one&#8217;s eyes to get a better view is a natural, timeless user interaction, and maps like <a href="http://blog.apps.chicagotribune.com/2011/03/08/making-maps-1/">this one</a>, which Boyer produced during his time at <em>The Tribune</em>, are far more intuitive in communicating information upon first glance than many of the infoWindow-laden Google maps being produced by news organizations these days, many of them simply for the sake of being called &#8216;interactive&#8217; (for those of you fortunate enough not to be mapping nerds, infoWindow is just Google-speak for the clickable popup boxes you see in Google maps).</p>
<p>But Boyer&#8217;s minimalist mapping aesthetic only really works when you have one or two pieces of textual data you want to display for each geographic area. What if you have multiple pieces of information you want to display for each polygon, such as in <a href="http://www.texastribune.org/texas-counties-and-demographics/census/on-the-records-majority-texas-minority-races/">this snazzy map</a> from The Texas Tribune? Or, less likely but equally problematic, what if you need to bind non-textual data to your geographic polygons, such as <a href="http://mapbox.com/wax/">images</a> or Google Charts?  In cases such as these, you&#8217;re going to need to provide some sort of interaction that allows the user to expand and collapse the data for each area individually, or you&#8217;ll just end up with a chronic case of visual overload.</p>
<p>Not to mention, on a more abstract level, studies have repeatedly shown that users tend to spend more time on applications that provide direct feedback based upon their actions, even if that feedback sometimes makes their ability to consume information at first glance less efficient (see Donald Norman&#8217;s 2005 book <em><a href="http://www.goodreads.com/book/show/841.Emotional_Design">Emotional Design: Why We Love (Or Hate) Everyday Things</a>, </em>in which Norman asserts that the feeling of emotional satisfaction and empowerment users receive from triggering an action not only puts them in a clearer state of mind, but also makes them more engaged in the information at hand). So, if we&#8217;re trying to communicate geographic data to users as effectively as possible, it only makes sense that we&#8217;d want to have a certain degree of user interaction –– both for the sake of preventing visual overload and for making users feel more engaged. Such is the logic behind clickable infoWindows.</p>
<p>Still, clickable popups leave us with another problem: Users have to make the conscious and deliberate effort to click a polygon to see the data for that geographic area. Requiring clicks may sound like a trivial task to the designer or journalist-programmer, but for the short-attention span user, it can be an awful lot to ask for. To be fair, however, click-triggered popups may not be much of a problem for maps with only a few dozen polygons. But for maps with hundreds of small polygons –– say, census tracts or zip codes –– it can be very tedious to click the right polygon without first having to zoom into the map so far that you lose sight of the broader context.</p>
<p>That leads me back to a conversation I had a couple of months ago with a friend of mine from Columbia&#8217;s J-School, Michael Keller (<a href="http://twitter.com/mhkeller">@mhkeller</a>), who&#8217;s now working as the Senior Data Reporter at The Daily Beast. Michael insisted to me after a Hacks/Hacker event that providing hover interaction for maps is almost always a good thing, because hovers require less work on the part of the user. I&#8217;ll admit that I was dubious at the time, thinking of hovers as often unwanted, accidental triggers that can be distracting to the map and data at hand. But lately I&#8217;ve come around to his way of seeing things. If implemented correctly (i.e. no flashy interactions that cover up other parts of the map), hovers are almost always a good idea. For example, <a href="http://thenewyorkworld.com/public/2012/may/nyw-hotspots-map/index.php">this</a> recent map of New York Stop-and-Frisk data that Keller produced for <a href="http://thenewyorkworld.com">The New York World</a> using CartoDB and Leaflet is so detailed that it couldn&#8217;t possibly have worked without infoWindows, and would have been unwieldy if it relied on click-triggered interaction. By including floating mouseover capabilities, the map allows the user to scan quickly through the chloropleth map to see individual Stop-and-Frisk data from each block, without having to attempt to click through minute geographic areas.*</p>
<p>I&#8217;m certainly not advocating interaction for interaction&#8217;s sake (although such a case could be made, given the dynamics of the Web). But I am saying that hovers give more immediate visual feedback than click-triggered events, especially in maps. Hovers help draw users into the data without requiring them to seek it out consciously–– almost like a catchy lede would in a print narrative. So for the time-being, I&#8217;m pro-hover.</p>
<p><em>*Keller later messaged me letting me know that some examples which better illustrate the power of hovers include <a href="http://www.thenewyorkworld.com/2012/01/10/redistricting/">this map</a> and <a href="http://blog.timesunion.com/capitol/archives/114554/2010-voting-patterns-2012-district-lines-bigger-majorities/">this map</a>, both of which use hover functionality to help highlight the effects of proposed redistricting efforts in the New York State Senate. What you&#8217;ll also notice about Keller&#8217;s maps is that they include hover states, which I also think is a necessity, especially for maps that include lots of small polygons.</em></p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2984#comments" title="Comment on Making the case for hover interactions in maps">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2984</wfw:commentRss>
			<slash:comments>2</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Building a responsive site in less than 20 minutes</title>
			<link>http://carlvlewis.net/?p=2701</link>
			<comments>http://carlvlewis.net/?p=2701#comments</comments>
			<pubDate>Fri, 29 Jun 2012 01:55:19 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[information design]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[responsive design]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2701</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>With all this talk lately of the new era of responsive design, I realized today that I&#8217;ve yet to create anything that&#8217;s actually responsive. Given that I&#8217;ve only pondered using it in the implementation of complex, database-driven news sites, the task of tweaking every level of CSS to fit perfectly into a responsive grid system [...]<p><a href="http://carlvlewis.net/?p=2701#respond" title="Comment on Building a responsive site in less than 20 minutes">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><div id="attachment_2704" class="wp-caption aligncenter" style="width: 417px"><a href="http://carlvlewis.net/responsive"><img class="wp-image-2704 " title="Screen Shot 2012-05-19 at 10.10.15 PM" src="http://carlvlewis.net/wp-content/uploads/2012/05/Screen-Shot-2012-05-19-at-10.10.15-PM.png" alt="" width="407" height="213" /></a><p class="wp-caption-text">An ever-so-sleek responsive portfolio site I designed for a friend in less than 20 minutes using Skeleton as a foundation.</p></div>
<p>With all this talk lately of the new era of <a href="http://www.alistapart.com/articles/responsive-web-design/">responsive design</a>, I realized today that I&#8217;ve yet to create anything that&#8217;s actually responsive. Given that I&#8217;ve only pondered using it in the implementation of complex, database-driven news sites, the task of tweaking every level of CSS to fit perfectly into a responsive grid system has so far seemed too daunting to tackle.</p>
<p style="text-align: left;">But I got curious this afternoon, and found my way upon a cool new library called <a href="http://www.getskeleton.com/">Skeleton</a>, which bills itself as a &#8220;a beautiful boilerplate for responsive, mobile-friendly development.&#8221; Essentially, Skeleton is a collection of CSS and JS files that makes the mystery of responsive design seem a little less illusive. Upon uploading the package to my server, I was pleased to find a neatly-coded, easy-to-understand responsive site that I could play around with and tweak to my own liking. I ended up adjusting the grid size and performing some minor customizations to the underlying Skeleton structural CSS, but other than that, the development kit was, as it promised, &#8220;style agnostic.&#8221;</p>
<p>Since I didn&#8217;t have any specific projects I needed to be working on today, I decided to give Skeleton a whirl by designing a <a href="http://carlvlewis.net/responsive">new online portfolio</a> as a favor for my friend Daniel Medina. I&#8217;m not kidding – within 10 minutes I&#8217;d coded a fully satisfactory responsive portfolio site that looks beautiful on my iPhone and tablet.</p>
<p>So, if you&#8217;re feeling experimental, try Skeleton out. It&#8217;s exciting to see how quickly this technology is catching steam, and to see the actual workings of the responsive CSS in action firsthand. My next goal is to integrate a responsive layout into a more-powerful database-driven site, perhaps one designed in <a href="http://drupal.org/">Drupal</a>.</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2701#respond" title="Comment on Building a responsive site in less than 20 minutes">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2701</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Raw data as oxymoron</title>
			<link>http://carlvlewis.net/?p=2739</link>
			<comments>http://carlvlewis.net/?p=2739#comments</comments>
			<pubDate>Tue, 22 May 2012 11:35:32 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Uncategorized]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2739</guid>
						<description><![CDATA[	<p>Posted in <a href="http://carlvlewis.net/?cat=1" title="View all posts in Uncategorized" rel="category">Uncategorized</a></p><p><cite>"Raw data is both an oxymoron and a bad idea; to the contrary, data should be cooked with care." ~ <a href="" title="Raw data as oxymoron">Geoffrey Bowker, 2005</a></cite></p>
	Bowker is spot on. I can&#8217;t tell you how many times I&#8217;ve had to make order out of chaos from &#8220;raw data,&#8221; i.e. unintelligible, inaccurate spreadsheets.<p><a href="http://carlvlewis.net/?p=2739#respond" title="Comment on Raw data as oxymoron">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[	<p>Posted in <a href="http://carlvlewis.net/?cat=1" title="View all posts in Uncategorized" rel="category">Uncategorized</a></p><p><cite>"Raw data is both an oxymoron and a bad idea; to the contrary, data should be cooked with care." ~ <a href="" title="Raw data as oxymoron">Geoffrey Bowker, 2005</a></cite></p>
	<p>Bowker is spot on. I can&#8217;t tell you how many times I&#8217;ve had to make order out of chaos from &#8220;raw data,&#8221; i.e. unintelligible, inaccurate spreadsheets.</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2739#respond" title="Comment on Raw data as oxymoron">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2739</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>					
    	
		           	
    	    	<item>
			<title>Using data-viz to make a wire story stand out from the pack</title>
			<link>http://carlvlewis.net/?p=2548</link>
			<comments>http://carlvlewis.net/?p=2548#comments</comments>
			<pubDate>Mon, 07 May 2012 05:14:13 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2548</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>I&#8217;ve been interested lately in finding examples of online-only, collaborative, non-profit newsrooms who&#8217;ve utilized the power of data visualization techniques to give added value to stories that otherwise wouldn&#8217;t necessarily be unique, and in doing so beat out legacy news organizations who published a text narrative alone. Take, for example, this data-rich story and interactive map displaying statewide testing results [...]<p><a href="http://carlvlewis.net/?p=2548#respond" title="Comment on Using data-viz to make a wire story stand out from the pack">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><p>I&#8217;ve been interested lately in finding examples of online-only, collaborative, non-profit newsrooms who&#8217;ve utilized the power of data visualization techniques to give added value to stories that otherwise wouldn&#8217;t necessarily be unique, and in doing so beat out legacy news organizations who published a text narrative alone. Take, for example, this <a href="http://www.njspotlight.com/stories/12/0503/1747/">data-rich story</a> and interactive map displaying statewide testing results published by <a href="http://njspotlight.com">NJSpotlight</a> Friday. While the news that only 8 out of 10 graduating seniors had passed New Jersey&#8217;s current standardized test in 2011 was widely reported across the state last week, including by the<em><a href="http://www.nj.com/news/index.ssf/2012/05/nj_high_school_graduation_rate_1.html"> Star-Ledger</a></em> in Newark and by <em><a href="http://www.pressofatlanticcity.com/news/breaking/high-school-graduation-rates-have-dropped-statewide-under-new-formula/article_051bca92-93d9-11e1-a20c-001a4bcf887a.html">The Press of Atlantic City</a></em>, only NJSpotlight took advantage of the story&#8217;s strong data element to produce a more concise, data-driven visual narrative.</p>
<p>So NJSpotlight obviously deserves kudos for the gap they&#8217;re filling in New Jersey journalism. What&#8217;s more, the job they did on the <a href="http://www.njspotlight.com/stories/12/0503/1747/">interactive map</a> was fairly sophisticated (I&#8217;ve still yet to figure out how to overlay such a highly customized legend onto a Google map). But as is always the case with any deadline project, there&#8217;s room for improvement. Let&#8217;s take a look at the good and the bad of NJSpotlight&#8217;s Friday package on state test results.</p>
<p>First off, this is a classic example of a story where county and/or municipality polygons with a colored fill layered on top of a Google Map brings new insight to a widely reported story. Not only can we immediately see from the map that most of the state fell within the 75 to 90 percent range in terms of passing rates, but we can also clearly tell that the north-central region of the state, particularly near the Pennsylyvania border, earned significantly higher scores than the rest of New Jersey. The pop-up table with information on vocational and charter schools also adds an additional layer of nuance to the piece, and does a decent job of displaying the numbers in a table-like format.</p>
<p>The map colors follow a somewhat logical pattern, with green representing high-passing rates and red representing lower passing rates. But the orange, yellow and blue colors that fall in the middle do more to obfuscate than they do to help visualize. Without referencing the legend, how is the user supposed to know that blue is better than yellow, or that green is better than blue? What&#8217;s more, the combination of such bright shades of colors from opposite ends of the color spectrum makes the map less pleasing on the eye than it would&#8217;ve been had the designer chosen more subtle, complimentary shades. I understand the desire to have red represent &#8216;negative&#8217; and green represent &#8216;positive,&#8217; but if NJSpotlight had went with a graduated color scale from red to green, with neutral-based mid-values such as the ones I used in <a href="http://carlvlewis.net/?p=2024">this recent map</a> on nationwide obesity rates, the map would&#8217;ve been not only aesthetically more appealing, but easier to read.</p>
<p>Another minor criticism I could make of the map is the designer&#8217;s decision to set the polygon-fills to solid colors with 100 percent opacity. This obscures the underlying view of which cities and townships each shape contains. While I understand the thought-process that likely went into this decision – it&#8217;s hard to make disparate colors, especially orange and yellow, stand out when layered on a slightly orange-tinted map with road and highway features – the designer could have easily used a tool such as <a href="http://colorbrewer2.org/">colorbrewer2.org</a> to generate some nice equidistant colors that would&#8217;ve looked fine set to an opacity of about 50 or 60 percent.</p>
<p>For the sake of thoroughness, I also want to address the included table that contains the charter and vocational school data. I like the fact that NJSpotlight chose to alternate the shades of background color for every other row in the table. It helps distinguish each row more easily from its neighbor, and gives an extra visual attribute to what easily could have been a stale grid. My only recommendations might be to split up every five or six rows with a dividing line, and to incorporate a bar chart, if possible, for one of the values in the cell (presumably, the most important value, the percent passing column).</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2548#respond" title="Comment on Using data-viz to make a wire story stand out from the pack">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2548</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Visualizing 2012 census estimates using CartoDB and Leaflet</title>
			<link>http://carlvlewis.net/?p=2742</link>
			<comments>http://carlvlewis.net/?p=2742#comments</comments>
			<pubDate>Sun, 06 May 2012 19:23:43 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[cartodb]]></category>
		<category><![CDATA[census data]]></category>
		<category><![CDATA[chloropleth maps]]></category>
		<category><![CDATA[geojson]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[leaflet]]></category>
		<category><![CDATA[mapping]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2742</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p>I&#8217;ve been tinkering around with some new mapping tools lately, and figured I&#8217;d put them to good use by displaying the 2011-2012 population estimates released last week by the U.S. Census Bureau. The inherently geographical nature of the census makes it a data set just begging to be mapped. Rather than the de facto Google [...]<p><a href="http://carlvlewis.net/?p=2742#comments" title="Comment on Visualizing 2012 census estimates using CartoDB and Leaflet">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a></p><p>I&#8217;ve been tinkering around with some new mapping tools lately, and figured I&#8217;d put them to good use by displaying the <a href="http://www.census.gov/popest/">2011-2012 population estimates</a> released last week by the U.S. Census Bureau. The inherently geographical nature of the census makes it a data set just begging to be mapped.</p>
<p>Rather than the de facto <a href="https://developers.google.com/maps/documentation/javascript/">Google Maps JavaScript API V3</a>, I decided to go with <a href="http://cartodb.com">CartoDB</a> and <a href="http://leaflet.cloudmade.com">Leaflet</a> to see what I could produce.</p>
<p>As I mentioned in a recent <a href="http://carlvlewis.net/?p=2422">post</a>, CartoDB offers an excellent <a href="http://google.com/fusiontables">Fusions</a>-esque interface, although it allows for far less front-end customization and requires more beneath the hood programming. Nonetheless, CartoDB can make pretty maps right out of the box, which you can then fully customize using the CartoDB API and basic SQL statements. There&#8217;s one caveat, however: The service only allows you to upload 5 tables for free. That could be a dealbreaker for cash-strapped news organizations and freelance data journalists.</p>
<p>Anyhow, I downloaded a .zip shapefile package of all 159 Georgia counties from the <a href="http://www.census.gov/geo/www/cob/co2000.html">U.S. Census Bureau</a>, then brought the package into CartoDB using the service&#8217;s default upload interface. Using Excel, I calculated the <a href="http://www.mathgoodies.com/lessons/percent/change.html">percent change</a> from the most recent population estimates to last year&#8217;s estimates. I then added the resulting values as a column in my CartoDB table, which you can see <a href="https://carlvlewis.cartodb.com/tables/2948">here</a>.</p>
<p>After playing a bit with the <a href="http://developers.cartodb.com/documentation/cartodb-apis.html">API</a>, I was able to format a diverging chloropleth map from my table with the following style parameters, written using <a href="http://0to255.com">0to255</a> to ensure an equidistant color scheme:</p>
<pre name="code" class="css">
#statewidepop {
   line-color:#FFFFFF;
   line-width:1;
   line-opacity:0.52;
   polygon-opacity:1;
}
#statewidepop [percent_change<=5.5] {
   polygon-fill:#558740
}
#statewidepop [percent_change<=4] {
   polygon-fill:#609948
}
#statewidepop [percent_change<=3] {
   polygon-fill:#6AA84F
}
#statewidepop [percent_change<=2.25] {
   polygon-fill:#BECFA8
}
#statewidepop [percent_change<=1.5] {
   polygon-fill:#D0D8BB
}
#statewidepop [percent_change<=0.75] {
   polygon-fill:#B8CCA1
}
#statewidepop [percent_change<=0.3] {
   polygon-fill:#D9DCC4
}
#statewidepop [percent_change<=0] {
   polygon-fill:#D3BAAF
}
#statewidepop [percent_change<=-0.5] {
   polygon-fill:#E7D1C5
}
#statewidepop [percent_change<=-1] {
   polygon-fill:#D8A696
}
#statewidepop [percent_change<=-2] {
   polygon-fill:#C36E59
}
#statewidepop [percent_change<=-3] {
   polygon-fill:#BC5942
}
#statewidepop [percent_change<=-4] {
   polygon-fill:#B34027
}
#tl_2009_13_county[percent_change<=-5] {
   polygon-fill:#AB2B10
}
</pre>
<p>Check out the resulting map:</p>
<p><iframe src="https://carlvlewis.cartodb.com/tables/statewidepop/embed_map" width="500" height="305"></iframe><em></em></p>
<p>The map above shows the percent change in population from July 2010 to July 2011 in all 159 Georgia counties, as estimated by the U.S. Census Bureau. The darker the green, the higher the positive percent change. The darker the red, the higher the negative percent change. Click on a county to see its percent change.</p>
<p>Pretty nice, huh? But what if I want to customize the style of the pop-up windows or perform more advanced functions like creating custom image markers or switching between layers? That&#8217;s where <a href="http://leaflet.cloudmade.com">Leaflet</a>, an open-source JavaScript library, comes in handy.</p>
<h1>Using the Leaflet library</h1>
<p><iframe src="http://carlvlewis.net/leaflet/home%20copy.html" frameborder="no" scrolling="no" width="530" height="305"></iframe></p>
<p><em>The map above displays the estimated percent change in population of various midstate counties between July 2011 and July 2012. The greener the county, the higher its percent increase. The deeper red the county, the higher its percent decrease. Click on a county to see more precise totals, or select a group from the dropdown in the top right corner for a breakdown of the population changes by race.</em></p>
<p>To get a wider range of flexibility, I called up a segment of the statewide data – the counties within the <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=3&amp;ved=0CHsQFjAC&amp;url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMacon%2C_Georgia&amp;ei=77LBT8O0B6al2AW6qYlk&amp;usg=AFQjCNFR3fNx8wCTK88zuWVl30ObDsMuwg">Macon/Warner Robins</a> metropolitan area – using the <a href="http://leaflet.cloudmade.com">Leaflet</a> javascript. Leaflet allows you to reference layers from CartoDB or Google Maps from within its API, making integration a breeze. All you have to do is reference a <a href="http://developers.cartodb.com/documentation/cartodb-apis.html#section-7">few lines of code</a> and your CartoDB data will appear as a layer on your Leaflet map automagically. But even on its own, Leaflet is pretty robust, especially for being so lightweight.</p>
<p>In the map above, I took the county shapefile package from earlier, converted it to GeoJSON using <a href="http://www.kyngchaos.com/software/qgis">QGis</a>, then, following these <a href="http://leaflet.cloudmade.com/reference.html#geojson">parameters</a>, called up the GeoJSON data for the selected counties using the Leaflet script. For the underlying map tiles, I created a custom style using Cloudmade, then referenced it using my API key and the following line of script:</p>
<pre class="javascript">var cloudmade = new L.TileLayer('http://{s}.tile.cloudmade.com/41fc7e18cef34d6fb34756efd8240787/63501/256/{z}/{x}/{y}.png',</pre>
<p>Because I also wanted to show a breakdown of the data by race for the same geography, I added in a <a href="http://leaflet.cloudmade.com/reference.html#control-layers">custom control</a> menu that allows the user to switch between layers for easy comparison. In addition, I styled the popup to my liking, with green and red values to connote increase and decrease.</p>
<p>From there, I was able to add in the additional data sets of population change by race. For each demographic group, I created a corresponding <a href="http://leaflet.cloudmade.com/reference.html#layergroup">layer group</a>. Each layer group contained the data as well as the appropriate styles and colors. See the source code below:</p>
<pre name="code" class="javascript">var totalLayer = new L.LayerGroup();

citiesLayer.addLayer(geojsononeLayer)
           .addLayer(geojsontwoLayer)
           .addLayer(geojsonthreeLayer)
           .addLayer(geojsonfourLayer)
           .addLayer(geojsonfiveLayer)
           .addLayer(geojsonsevenLayer)
           .addLayer(geojsoneightLayer);

var whiteLayer = new L.LayerGroup();

whiteLayer.addLayer(geojsononewhiteLayer)
           .addLayer(geojsontwowhiteLayer)
           .addLayer(geojsonthreewhiteLayer)
           .addLayer(geojsonfourwhiteLayer)
           .addLayer(geojsonfivewhiteLayer)
           .addLayer(geojsonsevenwhiteLayer)
           .addLayer(geojsoneightwhiteLayer);
var blackLayer = new L.LayerGroup();

blackLayer.addLayer(geojsononeblackLayer)
           .addLayer(geojsontwoblackLayer)
           .addLayer(geojsonthreeblackLayer)
           .addLayer(geojsonfourblackLayer)
           .addLayer(geojsonfiveblackLayer)
           .addLayer(geojsonsevenblackLayer)
           .addLayer(geojsoneightblackLayer);

var asianLayer = new L.LayerGroup();

asianLayer.addLayer(geojsononeasianLayer)
           .addLayer(geojsontwoasianLayer)
           .addLayer(geojsonthreeasianLayer)
           .addLayer(geojsonfourasianLayer)
           .addLayer(geojsonfiveasianLayer)
           .addLayer(geojsonsevenasianLayer)
           .addLayer(geojsoneightasianLayer);

var otherLayer = new L.LayerGroup();

otherLayer.addLayer(geojsononeotherLayer)
           .addLayer(geojsontwootherLayer)
           .addLayer(geojsonthreeotherLayer)
           .addLayer(geojsonfourotherLayer)
           .addLayer(geojsonfiveotherLayer)
           .addLayer(geojsonsevenotherLayer)
           .addLayer(geojsoneightotherLayer);

map.addLayer(citiesLayer);

var overlayMaps = {
    "Total Population": citiesLayer,
    "White": whiteLayer,
    "Black": blackLayer,
    "Asian": asianLayer,
    "Other/Mixed": otherLayer
};

var layersControl = new L.Control.Layers(overlayMaps);

map.addControl(layersControl);</pre>
<p>All of this was accomplished using the built-in components of the Leaflet JavaScript API and only an hour or so of data analysis in Excel. Next goal? Adding <a href="http://palewi.re/posts/2012/03/26/leaflet-recipe-hover-events-features-and-polygons/">mouseover capabilities</a>.</p>
<p>&nbsp;</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2742#comments" title="Comment on Visualizing 2012 census estimates using CartoDB and Leaflet">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2742</wfw:commentRss>
			<slash:comments>6</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Overlaying a bubble chart onto a Google map</title>
			<link>http://carlvlewis.net/?p=2422</link>
			<comments>http://carlvlewis.net/?p=2422#comments</comments>
			<pubDate>Sat, 05 May 2012 01:29:08 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
		<category><![CDATA[bubble charts]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[google maps javascript api v3]]></category>
		<category><![CDATA[mapping]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2422</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>Others may hate, but I&#8217;m a big fan of using bubbles to display data. When implemented correctly (i.e. scaled in terms of area instead of diameter), bubbles can be an aesthetically appealing and concise way to represent the value of data points in an inherently visual format. Bubbles are even more useful when they include [...]<p><a href="http://carlvlewis.net/?p=2422#comments" title="Comment on Overlaying a bubble chart onto a Google map">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=153" title="View all posts in Data Visualization" rel="category">Data Visualization</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><p>Others may <a href="http://junkcharts.typepad.com/junk_charts/2009/01/popping-the-bubble-so-to-speak.html">hate</a>, but I&#8217;m a big fan of using bubbles to display data. When implemented correctly (i.e. scaled in terms of area instead of diameter), bubbles can be an aesthetically appealing and concise way to represent the value of data points in an inherently visual format. Bubbles are even more useful when they include interactivity, with events like mouseover and zoom allowing users to drill down and compare similar-sized bubbles more easily than they can in static graphics. So, when I was recently working on a <a href="http://carlvlewis.net/autismdataviz/WebAppHome.html">class project</a> on autism diagnoses in New York City, I decided to use bubbles to represent the percentage of students with individualized education plans at all 1250 or so K-8 New York City schools.</p>
<p>Almost by default, I turned to Google Maps JavaScript API V3, mainly because I&#8217;m quasi-familiar with its basic functions and event handlers (as I point out later in  this post, I didn&#8217;t realize that a nifty new service called <a href="http://cartodb.com">CartoDB</a> would have automated most of what I was trying to do, albeit without nearly the level of customization). Nonetheless, based on a <a href="http://karlagius.com/2011/03/26/visualizing-data-with-google-maps/">tutorial</a> from Karl Agius, as well as some infoWindow help from my data viz professor, <a href="http://susanemcgregor.com">Susan McGregor</a>, I created the following interactive bubble map of NYC schools based upon the number of special needs, or IEP, students at each school. The larger the bubble, the greater percentage of special needs students a school has. Click <a href="http://carlvlewis.net/mapTest/">here</a> to see the map full-screen, or <a href="http://carlvlewis.net/bubbleMap.zip">here</a> to download a .zip of my source files for your own customization purposes.</p>
<p><iframe src="http://carlvlewis.net/mapTest/" frameborder="0" width="550" height="330"></iframe><br />
<em>Each bubble on this map represents one of New York City&#8217;s approximately 1,250  K-8 public schools, including charters. The larger the bubble, the higher the percentage of students with individualized education plans (IEP). Click on a bubble to find out more about the school, or click anywhere within a district boundary to see an overall average IEP rate for the district. Zoom and pan to see other parts of the city.</em></p>
<p>You&#8217;ll notice the opacity for the bubbles is set to 40 percent. This allows us to get a quick visual of the locations with the highest density of special needs students, given that those areas on the map will naturally be darker because they have multiple semi-opaque layers that overlap. Setting a low opacity also prevents overlapping bubbles from covering up one another. You&#8217;ll also notice that the map includes polygons for each school district, which you can click on to get an average IEP rate for the entire district. I decided against setting gradated fill colors for the school district shapes so as to avoid implying causation, as well as to lessen the visual clutter.*</p>
<h1>Preparing the data</h1>
<p>To create the map, I first had to download the underlying data from the New York City Department of Education <a href="http://schools.nyc.gov/AboutUs/data/default.htm">database</a> as a .csv, then import it into Excel to clean it up and leave only the relevant information. Although the dataset I had only included street addresses split into multiple columns, I was able to use the <a href="http://office.microsoft.com/en-us/excel-help/concatenate-HP005209020.aspx">concatenate</a> function in Excel to merge the street, city, state and zip columns to get a full street address. From there, I used my <a href="http://www.findlatitudeandlongitude.com/batch-geocode/#.T6V0Op9Yvk0">favorite batch geocoding service</a> to convert the addresses into geographic coordinates that the Google Maps API can read. Check out my resulting .csv file <a href="http://carlvlewis.net/nycpubschools.csv">here</a> for an example. Then I imported the .csv into a Google Spreadsheet, and pasted the resulting spreadsheet&#8217;s URL into dataSourceURL field in the JavaScript of my main index.html file. Here&#8217;s how that looked in my code:</p>
<pre name="code" class="javascript">
var dataSourceUrl = "https://docs.google.com/spreadsheet/ccc?key=0Au4D8Alccn4xdHNJdXJmeTdYcEtpRXE1QXRucWtEN3c";
var onlyInfoWindow;

google.load("visualization", "1");
google.load("maps", "3", {other_params:"sensor=false"});

google.setOnLoadCallback(getData);
</pre>
<h1>Drawing the bubbles</h1>
<p>Using the &#8216;Circle&#8217; marker style from the <a href="https://developers.google.com/maps/documentation/javascript/">Google Maps JavaScript V3 API</a>, I set each row in the spreadsheet to draw a bubble whose size corresponded to its value. It works by calling up the &#8216;size&#8217; column in my spreadsheet, which contains the IEP data I want to display, and then drawing an overlay of bubbles based upon those values. Credit again to Karl Agius for helping me figure out this part of the script. </p>
<pre name="code" class="javascript">
// This first array is where you can change the size and styling of the bubbles.
function Bubble(data, options) {
    this.data = data;
    if (options) 
		this.options = options 
	else 
		this.options = {
			radiusForPercentage:1000,
			text:{
				visible:false,
				minimumZoom:13,
				maximumZoom:15
			},
			bubble:{
				fill:{color:"#709ED9", opacity:0.6},
				stroke:{color:"#709ED9", weight:1, opacity:0.3}
			}
		};
	this.totalSize = this.getTotalSize(this.data);
}

Bubble.prototype = new google.maps.OverlayView;

Bubble.prototype.onAdd = function() {
	for (var row = 0; row < this.data.getNumberOfRows(); row++) 
		this.drawBubble(this.data, this.options, row);
}

Bubble.prototype.draw = function() {
	if (this.options.text.visible)
		for (var row = 0; row < this.data.getNumberOfRows(); row++) 
			this.drawText(this.data, this.options, row);
}

Bubble.prototype.getTotalSize = function(data) {
    var totalSize = 0;
    
	for (var row = 0; row < data.getNumberOfRows(); row++)
        totalSize += data.getValue(row, 1);
                
    return totalSize;
}

Bubble.prototype.drawBubble = function(data, options, row) {
	
    var sizeOfLocation = data.getValue(row, 1);
    var percentageOfTotal = (sizeOfLocation / this.totalSize) * 100;
			
    var radiusForLocation = options.radiusForPercentage * percentageOfTotal;
			
    var marker = new google.maps.Circle({
        center: new google.maps.LatLng(data.getValue(row, 2), data.getValue(row, 3)),
        fillColor:options.bubble.fill.color,
        fillOpacity:options.bubble.fill.opacity,
        strokeColour:options.bubble.stroke.color,
        strokeWeight:options.bubble.stroke.weight,
        strokeOpacity:options.bubble.stroke.opacity,
        radius:radiusForLocation
 });
	// This last command actually places the Circle markers we just made on the map.
	marker.setMap(this.getMap());
</pre>
<p>You can change the default size of the bubbles with the radiusForPercentage value, and set the colors using the fill and stroke fields. You can also set a minimum and maximum zoom so that users can only see the part of the map you want them to see.</p>
<h1>Adding interactivity</h1>
<p>Next, to make the bubbles clickable, I added an on-click event listener that set each bubble marker to fetch the corresponding data from my Google spreadsheet and add it to an infoWindow. Here's what that looked like:</p>
<pre name="code" class="javascript">var contentString = '
<div id="content">School Name' + data.getValue(row, 0) + 'Percent IEP students:'+sizeOfLocation+'Percent free-lunch:' + data.getValue(row, 4) + '</div>
';

var infowindow = new google.maps.InfoWindow({
content: contentString,
position: new google.maps.LatLng(data.getValue(row, 2), data.getValue(row, 3))

});

google.maps.event.addListener(marker, 'click', function() {
if(onlyInfoWindow != null){
onlyInfoWindow.close();
}

infowindow.open(this.getMap());
onlyInfoWindow = infowindow;

});</pre>
<p>As you can see, I referenced each value in my spreadsheet by adding in its row number. Later, I went back in and added another row of data that displayed free-lunch statistics as well, which is why you see a reference to row 4.</p>
<h1>Overlaying the school district polygons</h1>
<p>To place the school polygons onto the map, I added a new overlay that pointed to a Google Fusions table containing the KML geographic boundaries. This is what that looked like:</p>
<pre name="code" class="javascript">
var schoolDistricts = new google.maps.LatLng(41.850033, -87.6500523);

var layer = new google.maps.FusionTablesLayer({
  query: {
    select: 'geometry',
    from: '3621394'
  },
  styles: [{
  polygonOptions: {
    fillColor: "#FAFBFF",
    fillOpacity: 0
    }
  }
  ]}
  );

layer.setMap(map);
  }
</pre>
<p>The 'from' field should correspond to your Fusions Table's six-digit ID, and the 'select' field should reference the column in your table that contains the KML geographic data.</p>
<h1>A simpler new tool to do roughly the same thing</h1>
<p>Ultimately, however, it may have been easier to use the WYSIWYG editor from <a href="http://cartodb.com">CartoDB</a>, a premium mapping service with a front-end interface similar to Google Fusions Tables except that it allows you to draw bubbles without having to dig into the API. See what happened when I uploaded my spreadsheet to CartoDB and set similar style attributes:</p>
<p><iframe src="https://carlvlewis.cartodb.com/tables/nycpubschools/embed_map" width="550" height="330"></iframe></p>
<p>Which map is better? Personally I think the hand-coded Google Maps API version is better in terms of aesthetics and usability. But was it worth the extra effort? You tell me.</p>
<p><i>*<a href="http://www.propublica.org/site/author/jennifer_lafleur">Jennifer LaFleur</a>, ProPublica's director of computer-assisted reporting, later pointed out to me that I could easily add a gradated fill for each of the school district polygons based upon poverty levels, provided that I pick the right color-scheme to complement the blue bubbles. I guess I was just a bit leery from a design standpoint about what one color on top of another would look like.</i></p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2422#comments" title="Comment on Overlaying a bubble chart onto a Google map">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2422</wfw:commentRss>
			<slash:comments>2</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>Why calculus matters when it comes to data-driven stories</title>
			<link>http://carlvlewis.net/?p=2373</link>
			<comments>http://carlvlewis.net/?p=2373#comments</comments>
			<pubDate>Wed, 18 Apr 2012 07:00:50 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[standard deviation]]></category>
		<category><![CDATA[z-value]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2373</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>A quick refresher from my data visualization professor here at Columbia a couple of weeks ago reminded me why I was forced to spend all those grueling hours calculating standard deviation back in high school. See, when you&#8217;re using a data set to tell a story, the first step is to understand what that data [...]<p><a href="http://carlvlewis.net/?p=2373#respond" title="Comment on Why calculus matters when it comes to data-driven stories">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><p>A quick refresher from my data visualization <a href="http://susanemcgregor.com/">professor</a> here at Columbia a couple of weeks ago reminded me why I was forced to spend all those grueling hours calculating standard deviation back in high school.</p>
<p>See, when you&#8217;re using a data set to tell a story, the first step is to understand what that data says. And to do that, you&#8217;ve got to have a good idea of the range and variation of the values at hand. Not only can figuring that information out help you determine whether there&#8217;s any statistical significance to your data set, but it can also pinpoint outliers and possible errors that may exist within the data before you begin the work of visualizing it.</p>
<p>Thanks to powerful processing programs like Excel, we can figure out the variability of data sets pretty easily using the program&#8217;s built-in standard deviation function (remember <a href="http://standard-deviation.appspot.com/">this</a> intimidating-looking equation from calculus class?). Still, it always helps to know how to calculate the information out by hand, if only to get a conceptual idea of why numbers such as the standard deviation (the variability of a data-set) and the z-value (the number of standard deviations a given value is away from the mean) even matter in the first place when it comes to data visualization.</p>
<p>So, to brush up on my formulas and also better understand the numbers behind an <a href="http://carlvlewis.net/?p=2024">actual story assignment</a> for one of my classes, I recently hand-calculated the standard deviation and z-values for a set of data on state-by-state obesity rates. From my calculations, I was able to use the standard deviation (3.24) to determine that, on average, most states fell within the middle of the bell-curve for the average national obesity rate (27.1 percent) . In addition, the z-values helped me understand which states stood out from the pack as possible outliers (Mississippi is by far the most obese with a 2.13 z-value, Colorado the least obese with a -1.9 z-value). To get an idea of how those formulas look hand-calculated in Excel, check out my spreadsheet <a href="http://carlvlewis.net/Lewis_stateobesityrates_standarddev.xlsx">here</a>. And keep these formulas in mind while working on your next data story. They can potentially save you time and effort by helping you figure out what your data set says <em>before</em> you have to go through the often-lengthy process of visualizing it.</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2373#respond" title="Comment on Why calculus matters when it comes to data-driven stories">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2373</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>		
		
		           	
    	    	<item>
			<title>What makes BostonGlobe.com &#8220;the world&#8217;s best designed website&#8221;</title>
			<link>http://carlvlewis.net/?p=2345</link>
			<comments>http://carlvlewis.net/?p=2345#comments</comments>
			<pubDate>Mon, 16 Apr 2012 18:02:18 +0000</pubDate>
			<dc:creator>Carl V. Lewis</dc:creator>
					<category><![CDATA[Blog]]></category>
		<category><![CDATA[Data Viz Coursework Blog]]></category>
		<category><![CDATA[bostonglobe.com]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[interactive design]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[Typography]]></category>
						<guid isPermaLink="false">http://carlvlewis.net/?p=2345</guid>
						<description><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p>With the Pulitzer Price announcements coming up later this afternoon, you&#8217;d think I&#8217;d be writing about whose up for the &#8220;Best Deadline Reporting&#8221; or &#8220;Best Public Service Journalism&#8221; prizes. But instead I want to talk about a different media award doled out during the past week: BostonGlobe.com&#8217;s designation as the &#8220;world&#8217;s best designed website&#8221; by [...]<p><a href="http://carlvlewis.net/?p=2345#respond" title="Comment on What makes BostonGlobe.com &#8220;the world&#8217;s best designed website&#8221;">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://carlvlewis.net/?cat=80" title="View all posts in Blog" rel="category">Blog</a>,<a href="http://carlvlewis.net/?cat=50" title="View all posts in Data Viz Coursework Blog" rel="category">Data Viz Coursework Blog</a></p><p style="text-align: center;"><img class=" wp-image-2350 aligncenter" title="Screen Shot 2012-04-16 at 1.30.23 PM" src="http://carlvlewis.net/wp-content/uploads/2012/04/Screen-Shot-2012-04-16-at-1.30.23-PM.png" alt="" width="449" height="281" /></p>
<p>With the Pulitzer Price announcements coming up later this afternoon, you&#8217;d think I&#8217;d be writing about whose up for the &#8220;Best Deadline Reporting&#8221; or &#8220;Best Public Service Journalism&#8221; prizes. But instead I want to talk about a different media award doled out during the past week: BostonGlobe.com&#8217;s designation as the <a href="http://www.snd.org/2012/04/snd33-worlds-best-designed-website-bostonglobe-com/">&#8220;world&#8217;s best designed website&#8221;</a> by the Society for News Design. Put simply, I can&#8217;t say I disagree.</p>
<p>Yet before I divulge in my effusive praise of the folks in Boston, let me point out that I&#8217;m still somewhat skeptical of the business-logic behind The Globe&#8217;s <a href="http://www.huffingtonpost.com/2011/09/12/boston-globe-launches-pay-site_n_957410.html">decision</a> to launch its <a href="http://bostonglobe.com">paywall-only site</a> last fall alongside its primary news portal, <a href="http://boston.com">Boston.com</a>. From a revenue standpoint, I can&#8217;t see the full-paywall site, BostonGlobe.com, bringing in nearly enough subscription income to compensate for the traffic and ad dollars it will, and to some degree <a href="http://www.quantcast.com/boston.com">already has</a>, leeched from Boston.com (at last count, in February, BostonGlobe.com had only recruited about <a href="http://www.mediabistro.com/mediajobsdaily/the-nyt-company-has-406000-paid-digital-subscribers_b9817">16,000 paid digital subscribers</a>, many of whom had taken advantage of the site&#8217;s introductory offer of 99 cents for the first four weeks but may not stick it out past the trial period). It might&#8217;ve been wiser for the paper to start out with a metered paywall to warm users to the idea of paying for content before erecting a full-blown ten-foot-tall paywall around its most valuable content under a new, separate domain name. But then again, who really knows – maybe it&#8217;s a step in the right direction longterm? I&#8217;m not the one having to make the tough calls, so I&#8217;m in no position to judge.</p>
<p>At any rate, the segregation of the two sites has given the paper&#8217;s parent company the freedom to make BostonGlobe.com a rich, immersive and interactive user experience that few other news organizations can match. Why, you ask? Because of a little trend gaining steam in the development world called <a href="http://www.alistapart.com/articles/responsive-web-design/">&#8220;responsive design.&#8221; </a>See, BostonGlobe.com isn&#8217;t only a standout site because of its sophisticated use of white space, its wholehearted <a href="http://fontsinuse.com/bostonglobe-com/">embrace of web fonts</a> and its visual-first approach to story art, but also because of its cross-platform capabilities. No matter what device you view BostonGlobe.com on – desktop, tablet or mobile – the site retains its same slick look and feel. The site&#8217;s adaptive technology allows it to detect the screen size of the user, then adjust its layout to fit the exact resolution at hand. On desktops, that means content stretches to fill the entire browser window, and the grid restructures itself appropriately when you decrease or increase the size of the window. This eliminates the need for time-honored design standards like the <a href="http://960.gs/">960 grid-system</a>, which is based upon the Desktop-centric idea that all users have at least a 960px resolution. Now, the grid can be as big, or as small, as the user wants it to be.</p>
<p>The site&#8217;s successful display of a dynamic range of real-time content on any-sized device also essentially eliminates the need for the &#8220;app-based&#8221; environment that&#8217;s been the staple of the iOS5 and Android operating systems in recent years. To test it out, I gave the site a whirl on my iPad, and was pleased to see the front page neatly rearrange itself to fit the new orientation, just as any of the best platform-specific news apps out there do, including <a href="http://itunes.apple.com/us/app/the-new-yorker-magazine/id370614765?mt=8">The New Yorker </a>and <a href="http://itunes.apple.com/us/app/wired-magazine/id373903654?mt=8">Wired</a> apps for iPad. But just because BostonGlobe.com doesn&#8217;t <em>need</em> a native app to display its content beautifully on tablet and mobile devices doesn&#8217;t mean that it won&#8217;t be missing out on the growing app-centric marketplace for publishers. As Apple and Google continue to centralize digital consumption patterns into the app-based model, BostonGlobe.com may be a little too ambitious in thinking it doesn&#8217;t need to play nice with the big-boy tech companies to reach its audience. On the other hand, however, it could prove to be a brilliant move for the paper, setting an example for other publishers and app-based companies in general who want to break free from the often constricting, not to mention pricey, cost of participating in the app marketplace.</p>
<p>For its design alone, BostonGlobe.com deserves any number of awards. Its bold, minimalist interface allows content to shine above all else, free from clutter and distraction. And with high-res horizontal photos, block-quotes, inline video and stylized headlines that grab your attention without hurting your eyes, that content stands out even more. What&#8217;s more, the site has the <a href="http://www.boston.com/bostonglobe/features/">functionality</a> to back up its aesthetics. Its &#8220;Save&#8221; feature allows users to bookmark articles for reading offline on any device, which, even for sites without responsive design, is a brilliant feature for a news site to implement. Moreover, its &#8220;Story Flow&#8221; panel at the bottom of each article allows users to click seamlessly through to stories on similar subjects, just as readers would in an old-fashioned newspaper with physical sections. Which leaves me with one nagging question: Is BostonGlobe.com too imitative of physical newspapers to attain success in today&#8217;s short attention-span digital audience? Is it <em>too</em> skewmorphic to succeed in an SEO-driven, hyperlinked news economy?</p>
<p>I guess we&#8217;ll have to wait and see.</p>
<div id="fcbk_share"></div><p><a href="http://carlvlewis.net/?p=2345#respond" title="Comment on What makes BostonGlobe.com &#8220;the world&#8217;s best designed website&#8221;">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://carlvlewis.net/?feed=rss2&amp;p=2345</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>		
		
	</channel>
</rss>

