<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Stevendkay&#039;s Blog</title>
	<atom:link href="http://stevendkay.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://stevendkay.wordpress.com</link>
	<description>geek + laptop + camera</description>
	<lastBuildDate>Sat, 29 May 2010 18:50:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='stevendkay.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Stevendkay&#039;s Blog</title>
		<link>http://stevendkay.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://stevendkay.wordpress.com/osd.xml" title="Stevendkay&#039;s Blog" />
	<atom:link rel='hub' href='http://stevendkay.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Parsing USGS BIL Digital Elevation Models in Python</title>
		<link>http://stevendkay.wordpress.com/2010/05/29/parsing-usgs-bil-digital-elevation-models-in-python/</link>
		<comments>http://stevendkay.wordpress.com/2010/05/29/parsing-usgs-bil-digital-elevation-models-in-python/#comments</comments>
		<pubDate>Sat, 29 May 2010 18:50:41 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BIL]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Cartography]]></category>
		<category><![CDATA[DEM]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[Format]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[USGS]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=334</guid>
		<description><![CDATA[The USGS have a digital elevation model covering most of the US, Hawaii and Puerto Rico. If you use the National Map Seamless Server it&#8217;s possible to select a region and download a digital elevation model in a number of formats. One of these, BIL, is a simple binary raster file, which can be read [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=334&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="attachment_342" class="wp-caption alignnone" style="width: 610px"><a href="http://stevendkay.files.wordpress.com/2010/05/kahoolawe.png"><img src="http://stevendkay.files.wordpress.com/2010/05/kahoolawe.png?w=600&#038;h=383" alt="" title="Kahoolawe elevation amp" width="600" height="383" class="size-full wp-image-342" /></a><p class="wp-caption-text">A false colour elevation map of the Hawaiian island of Kahoolawe</p></div>
<p>The USGS have a digital elevation model covering most of the US, Hawaii and Puerto Rico. If you use the <a href="http://seamless.usgs.gov/">National Map Seamless Server</a> it&#8217;s possible to select a region and download a digital elevation model in a number of formats. One of these, BIL, is a simple binary raster file, which can be read quite easily in Python &#8211; in this, I&#8217;ll base this on code from a <a href="http://stevendkay.wordpress.com/2009/09/05/beginning-digital-elevation-model-work-with-python/">previous post</a>.</p>
<p><strong>Getting the data</strong></p>
<ul>
<li>Go to <a href="http://seamless.usgs.gov/">National Map Seamless Server</a></li>
<li>The map is fairly intuitive, but if you get stuck check out their tutorial</li>
<li>When you use the download rectangle tool, make sure to click on &#8220;Modify data request&#8221; and choose the BIL data format (BIL_INT16) rather than the default &#8220;Arc_GIS&#8221;</li>
<li>Choose zip or TGZ </li>
<li>You&#8217;ll then download a compressed archive &#8211; may take a while</li>
<li>The archive contains lots of files; look at the contents of <strong>output_parameters.txt</strong>. This tells you the dimensions of the file. Make a note of the sizes.</li>
<li>Extract the .bil file &#8211; this is what has the raw data.</li>
</ul>
<p><strong>Extracting the binary elevation data from the BIL file</strong></p>
<p><pre class="brush: python;">
# USGS Seamless Server BIL Format Parser
#

import struct

# get these from the output_parameters.txt file
# included in the download
height=437
width=663

# where you put the extracted BIL file
fi=open(r&quot;my-extracted.bil&quot;,&quot;rb&quot;)
contents=fi.read()
fi.close()

# unpack binary data into a flat tuple z
s=&quot;&lt;%dH&quot; % (int(width*height),)
z=struct.unpack(s, contents)
</pre></p>
<p>After running this, z is now a tuple of <em>width*height</em> elements, with data stored in raster order (entries in row 1 from left-to-right, then row 2 from left-to-right, and so on)</p>
<p><strong>The struct module for reading binary data</strong></p>
<p><a href="http://docs.python.org/library/struct.html">struct</a> is a fantastic Python library, it really makes reading binary files pretty easy. Say we have a raster-layout binary file of 50 rows by 100 values per row. We&#8217;d expect 5000 values. Each value is an unsigned short (H) and little-endian (&lt;)</p>
<p>In this case, we build up a format specification like this<br />
&#8220;&lt;5000H&#8221;</p>
<p><strong>Plotting the end result</strong></p>
<p>And optionally, if you have matplotlib and numpy libraries, you can get a quick preview of the resulting array.</p>
<p><pre class="brush: python;">
from pylab import *
import numpy as np
import matplotlib.cm as cm

heights = np.zeros((height,width))
for r in range(0,height):
    for c in range(0,width):
        elevation=z[((width)*r)+c]
        if (elevation==65535 or elevation&lt;0 or elevation&gt;20000):
            # may not be needed depending on format, and the &quot;magic number&quot;
            # value used for 'void' or missing data
            elevation=0.0
        heights[r][c]=float(elevation)
imshow(heights, interpolation='bilinear',cmap=cm.prism,alpha=1.0)
grid(False)
show()
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=334&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/05/29/parsing-usgs-bil-digital-elevation-models-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/05/kahoolawe.png" medium="image">
			<media:title type="html">Kahoolawe elevation amp</media:title>
		</media:content>
	</item>
		<item>
		<title>Using R and ggplot2 to create a timeline visualization of UK government politics</title>
		<link>http://stevendkay.wordpress.com/2010/05/19/uk-government-timeline-1750-2010/</link>
		<comments>http://stevendkay.wordpress.com/2010/05/19/uk-government-timeline-1750-2010/#comments</comments>
		<pubDate>Wed, 19 May 2010 20:56:08 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Infovis]]></category>
		<category><![CDATA[infovis, infoviz]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[RGB]]></category>
		<category><![CDATA[sapply]]></category>
		<category><![CDATA[stripes]]></category>
		<category><![CDATA[timeline]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/2010/05/19/uk-government-timeline-1750-2010/</guid>
		<description><![CDATA[UK Government Timeline 1750-2010 Originally uploaded by stevefaeembra creating an abstract timeline chart with R and ggplot This was an attempt to visualise the ebb and flow of various political parties in the UK, over time. The data was made available on the Guardian DataBlog, so I thought I&#8217;d have a go at producing a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=306&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/stevefaeembra/4615956449/" title="photo sharing"><img src="http://farm5.static.flickr.com/4029/4615956449_b0b1d6e464_m.jpg" alt="" style="border:solid 2px #000000;" /></a><br />
<br />
<span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/stevefaeembra/4615956449/">UK Government Timeline 1750-2010</a><br />
<br />
Originally uploaded by <a href="http://www.flickr.com/people/stevefaeembra/">stevefaeembra</a><br />
</span>
</div>
<p><strong>creating an abstract timeline chart with R and ggplot</strong></p>
<p>This was an attempt to visualise the ebb and flow of various political parties in the UK, over time.</p>
<p>The <a href="http://www.guardian.co.uk/news/datablog/2010/may/12/british-prime-ministers-listed-spreadsheet">data </a> was made available on the Guardian DataBlog, so I thought I&#8217;d have a go at producing a timeline image, using vertical strips of colour to show which party was in power in each year.
</p>
<p>I&#8217;m not an expert in R, so there may well be a better way of doing this!</p>
<p>The steps taken were:-</p>
<ul>
<li>download the OpenOffice spreadsheet from the Google Spreadsheet linked to on the Guardian DataBlog. </li>
<li>remove footer rows (copyright notices at the foot of the spreadsheet). </li>
<li>tidy up headers in row 1 &#8211; simplify these to single words like &#8220;Party&#8221;</li>
<li>save as a CSV, using the pipe (|) character as a delimiter. I put this in <strong>c:\infoviz\data.csv</strong></li>
</ul>
<p>First of all, we need to load the CSV file into a data frame<br />
<pre class="brush: matlabkey;">
inp &lt;- read.table(&quot;c:\\infoviz\\data.csv&quot;,header=T, sep=&quot;|&quot;)
</pre></p>
<p>This works fine, but the column &#8216;Party&#8217; contains names like &#8220;Conservative&#8221;, &#8220;Labour&#8221; and &#8220;Liberal&#8221;.</p>
<p>How to convert this into something a bit more abstract, like a colour? The answer was to define a palette of colours&#8230;<br />
<pre class="brush: matlabkey;">
palette &lt;- c(&quot;blue&quot;, &quot;red&quot;, &quot;orange1&quot;, &quot;rosybrown&quot;, &quot;orange3&quot;, &quot;red4&quot;, &quot;blue4&quot;, &quot;grey&quot;) 
</pre></p>
<p>.. and use a function to change a party name to a colour mentioned in that array&#8230;<br />
<pre class="brush: matlabkey;">
getcol &lt;- function(party) { 
	if ( party==&quot;Conservative&quot; | party==&quot;Tory&quot; )
         r&lt;-1
     	else if ( party==&quot;Labour&quot; ) 
         r&lt;-2
     	else if ( party==&quot;Liberal&quot; ) 
         r&lt;-3
     	else if ( party==&quot;Whig&quot; ) 
         r&lt;-4
	else if (party==&quot;National Labour National Government&quot;) 
	   r&lt;-6
	else if (party==&quot;Conservative National Government&quot;) 
	   r&lt;-7
     	else 
         r&lt;-8
	return(palette[r])
}
</pre></p>
<p>Now, we can use the sapply function to map the values in the &#8220;party&#8221; column of the data frame into a colour..</p>
<p><pre class="brush: matlabkey;">
inp$PartyCol &lt;- sapply(inp$Party,getcol)
</pre></p>
<p>Now, the data frame has a column called &#8216;PartyCol&#8217; which maps &#8220;Conservative&#8221; to &#8220;blue&#8221;, &#8220;Labour&#8221; to &#8220;red&#8221; and so on.</p>
<p>So now, ggplot&#8230;</p>
<p><pre class="brush: matlabkey;">
qplot(factor(Year), title=&quot;history&quot;, data=inp, geom=&quot;bar&quot;, fill=factor(PartyCol), color=factor(PartyCol)) +scale_fill_identity(name=inp$PartyCol) +scale_colour_identity(name=inp$YearCol)
</pre></p>
<p>This shows a whole lot of labels and grids that I didn&#8217;t want&#8230;, </p>
<p><a href="http://stevendkay.files.wordpress.com/2010/05/nolabels.png"><img src="http://stevendkay.files.wordpress.com/2010/05/nolabels.png?w=561&#038;h=576" alt="" title="nolabels" width="561" height="576" class="alignnone size-full wp-image-329" /></a>
<div style="float:right;margin-left:10px;margin-bottom:10px;">
<p>&#8230;so I added these options to give a clear, blank theme&#8230;</p>
<p><pre class="brush: matlabkey;">
+ opts(panel.background = theme_rect(size = 1, colour = &quot;lightgray&quot;),panel.grid.major = theme_blank(),panel.grid.minor = theme_blank(),axis.line = theme_blank(),axis.text.x = theme_blank(),axis.text.y = theme_blank(),axis.title.x = theme_blank(),axis.title.y = theme_blank(), axis.ticks = theme_blank(),strip.background = theme_blank(),strip.text.y = theme_blank())
</pre></p>
<p>Here&#8217;s the whole source, if you&#8217;re brave enough to want to try this yourself!</p>
<p><pre class="brush: matlabkey;">
library(ggplot2)
library(rgb)
palette &lt;- c(&quot;blue&quot;, &quot;red&quot;, &quot;orange1&quot;, &quot;rosybrown&quot;, &quot;orange3&quot;, &quot;red4&quot;, &quot;blue4&quot;, &quot;grey&quot;) 
getcol &lt;- function(party) { 
	if ( party==&quot;Conservative&quot; | party==&quot;Tory&quot; )
         r&lt;-1
     	else if ( party==&quot;Labour&quot; ) 
         r&lt;-2
     	else if ( party==&quot;Liberal&quot; ) 
         r&lt;-3
     	else if ( party==&quot;Whig&quot; ) 
         r&lt;-4
	else if (party==&quot;National Labour National Government&quot;) 
	   r&lt;-6
	else if (party==&quot;Conservative National Government&quot;) 
	   r&lt;-7
     	else 
         r&lt;-8
	return(palette[r])
}
inp &lt;- read.table(&quot;c:\\infoviz\\data.csv&quot;,header=T, sep=&quot;|&quot;)
inp$PartyCol &lt;- sapply(inp$Party,getcol)
qplot(factor(Year), title=&quot;history&quot;, data=inp, geom=&quot;bar&quot;, fill=factor(PartyCol), color=factor(PartyCol)) +scale_fill_identity(name=inp$PartyCol) +scale_colour_identity(name=inp$YearCol) + opts(panel.background = theme_rect(size = 1, colour = &quot;lightgray&quot;),panel.grid.major = theme_blank(),panel.grid.minor = theme_blank(),axis.line = theme_blank(),axis.text.x = theme_blank(),axis.text.y = theme_blank(),axis.title.x = theme_blank(),axis.title.y = theme_blank(), axis.ticks = theme_blank(),strip.background = theme_blank(),strip.text.y = theme_blank())

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/306/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=306&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/05/19/uk-government-timeline-1750-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://farm5.static.flickr.com/4029/4615956449_b0b1d6e464_m.jpg" medium="image" />

		<media:content url="http://stevendkay.files.wordpress.com/2010/05/nolabels.png" medium="image">
			<media:title type="html">nolabels</media:title>
		</media:content>
	</item>
		<item>
		<title>Plotting postcode density heatmaps in R</title>
		<link>http://stevendkay.wordpress.com/2010/04/21/plotting-postcode-density-heatmaps-in-r/</link>
		<comments>http://stevendkay.wordpress.com/2010/04/21/plotting-postcode-density-heatmaps-in-r/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 20:38:49 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Infovis]]></category>
		<category><![CDATA[infovis, infoviz]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[density]]></category>
		<category><![CDATA[edinburgh]]></category>
		<category><![CDATA[EH]]></category>
		<category><![CDATA[heatmap]]></category>
		<category><![CDATA[population]]></category>
		<category><![CDATA[postcode]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[visualizing]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=292</guid>
		<description><![CDATA[Here in the UK, postcode geodata was recently released as part of the OS Opendata initiative. Although not the full postcode address file (PAF), it&#8217;s enough to be useful for visualisation purposes! I thought it&#8217;d be interesting to plot the density of postcodes in a heatmap, as a way of getting a visualisation of population [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=292&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://stevendkay.files.wordpress.com/2010/04/edinburgh-postcode-density2.png"><img src="http://stevendkay.files.wordpress.com/2010/04/edinburgh-postcode-density2.png?w=600&#038;h=317" alt="Postcode density heatmap for edinburgh" title="edinburgh-postcode-density-heatmap" width="600" height="317" class="alignnone size-full wp-image-295" /></a></p>
<p>Here in the UK, postcode geodata was recently released as part of the OS Opendata initiative. Although not the full postcode address file (PAF), it&#8217;s enough to be useful for visualisation purposes!</p>
<p>I thought it&#8217;d be interesting to plot the density of postcodes in a heatmap, as a way of getting a visualisation of population density.</p>
<p>I downloaded a copy from <a href="http://parlvid.mysociety.org:81/os/">MySociety</a>. The raw data uses the Ordnance Survey coordinate systems (Eastings and Northings), but MySociety also provide a version with  coordinates converted to the WGS84 datum (latitude and longitude). It gets better; one file per outcode (so all the EH postcodes go in one file, for example).</p>
<p>So how to plot this? </p>
<p>I&#8217;ve been using <a href="http://www.r-project.org/">R</a> with the <a href="http://had.co.nz/ggplot/">ggplot2</a> library for visualisations; it&#8217;s an amazing toolset, and you&#8217;d be surprised how few lines of code it takes to get results.</p>
<p>First of all, download the data.</p>
<p>Now, extract the data for the EH postcode area.</p>
<p>The first step is to load the extracted CSV file into a data frame. There are no column headers (header=F) and the file is comma separated (sep=&#8221;,&#8221;)</p>
<p><pre class="brush: matlabkey;">
inp &lt;- read.table(&quot;c:\\infoviz\\ehpostcode.csv&quot;,header=F, sep=&quot;,&quot;)
</pre></p>
<p>Next, a quick hack to remove certain postcodes which seem way out of the region of Edinburgh. I&#8217;ve yet to work out what these stray postcodes are.</p>
<p><pre class="brush: matlabkey;">
inp &lt;- subset(inp,inp$V10 != &quot;&quot;)
</pre></p>
<p>Now we bring in the ggplot2 library..<br />
<pre class="brush: matlabkey;">
library(ggplot2)
</pre></p>
<p>Now the plot itself.<br />
<pre class="brush: matlabkey;">
m &lt;- qplot(xlab=&quot;Longitude&quot;,ylab=&quot;Latitude&quot;,main=&quot;EH Postcode heatmap&quot;,geom=&quot;blank&quot;,x=inp$V3,y=inp$V4,data=inp)  + stat_bin2d(bins =200,aes(fill = log1p(..count..))) 
</pre></p>
<p>The stat_bin2d does the binned heatmap plot. It splits the area into a grid of 200&#215;200 (&#8216;bins&#8217;) and counts the number of postcodes in each grid square. These counts are then scaled logarithmically (fill = log1p(..count..)).</p>
<p>Finally, we plot this puppy.<br />
<pre class="brush: matlabkey;">
m 
</pre></p>
<p>That&#8217;s it! Five lines of code. </p>
<p>Here&#8217;s the whole chunk.. </p>
<p><pre class="brush: matlabkey;">
inp &lt;- read.table(&quot;c:\\infoviz\\ehpostcode.csv&quot;,header=F, sep=&quot;,&quot;)
inp &lt;- subset(inp,inp$V10 != &quot;&quot;)
library(ggplot2)
m &lt;- qplot(xlab=&quot;Longitude&quot;,ylab=&quot;Latitude&quot;,main=&quot;EH Postcode heatmap&quot;,geom=&quot;blank&quot;,x=inp$V3,y=inp$V4,data=inp)  + stat_bin2d(bins =200,aes(fill = log1p(..count..))) 
m 
</pre></p>
<p>If you set the boundaries of the x and y axes, you can then use the resulting image as an overlay in Google Earth.</p>
<p>I found that the heatmap is a reasonably good proxy for population density &#8211; but with exceptions. There are hotspots that turn out to be postal sorting offices &#8211; PO boxes and <em>post restante</em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/292/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=292&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/04/21/plotting-postcode-density-heatmaps-in-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/04/edinburgh-postcode-density2.png" medium="image">
			<media:title type="html">edinburgh-postcode-density-heatmap</media:title>
		</media:content>
	</item>
		<item>
		<title>Plotting points on an OpenStreetMap Export</title>
		<link>http://stevendkay.wordpress.com/2010/02/24/plotting-points-on-an-openstreetmap-export/</link>
		<comments>http://stevendkay.wordpress.com/2010/02/24/plotting-points-on-an-openstreetmap-export/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 21:49:40 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Basemap]]></category>
		<category><![CDATA[Cartography]]></category>
		<category><![CDATA[Flickr API]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=280</guid>
		<description><![CDATA[This map shows the location of pictures in a Flickr group superimposed on an OpenStreetMap (OSM) export. If you try plotting points directly on an OSM map, you&#8217;ll find that points are all over the shop. The reason is that OSM exports use the Mercator projection; you need to change the latitude and longitude coordinates [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=280&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://stevendkay.files.wordpress.com/2010/02/scotland-pinboard.png"><img src="http://stevendkay.files.wordpress.com/2010/02/scotland-pinboard.png?w=584&#038;h=568" alt="" title="flickr map of scotland" width="584" height="568" class="alignnone size-full wp-image-281" /></a></p>
<p>This map shows the location of pictures in a Flickr group superimposed on an <a href="http://www.openstreetmap.org/">OpenStreetMap</a> (OSM) export.</p>
<p>If you try plotting points directly on an OSM map, you&#8217;ll find that points are all over the shop. The reason is that OSM exports use the Mercator projection; you need to change the latitude and longitude coordinates into the Mercator projection.</p>
<p>Basemap to the rescue!</p>
<p>If you use the code in the <a href="http://stevendkay.wordpress.com/2010/01/14/creating-a-pinboard-map-of-geotagged-photos-in-a-flickr-pool/">previous post</a>, you can change the plotting code.</p>
<p><pre class="brush: python;">
from basemap import Basemap 
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
import numpy as np
import string
import matplotlib.cm as cm

x=[] #longitudes
y=[] #latitudes

fi=open(r'C:\infoviz\scotland_photos.csv','r')

linenum=0
for line in fi:
    if linenum&gt;0:
        line=string.replace(line, &quot;\n&quot;,&quot;&quot;)
        try:
            fields=string.split(line,&quot;,&quot;)
            lon,lat=fields[0:2]
            x.append(float(lon))
            y.append(float(lat))
        except:
            print &quot;Error!&quot;
    linenum+=1
fi.close()

m = Basemap(llcrnrlon=-8.0,llcrnrlat=54.5,urcrnrlon=1.5,urcrnrlat=59.5,lat_ts=20,
            resolution='h',projection='merc',lon_0=-4.36,lat_0=54.5)
x1,y1=m(x,y)
m.drawmapboundary(fill_color='white') # fill to edge
m.scatter(x1,y1,s=5,c='r',marker=&quot;o&quot;,cmap=cm.jet,alpha=1.0)

</pre></p>
<p>Rather than using basemap to draw the outline of Scotland, this script simply creates a scatter plot on a white background, like so:-</p>
<p><a href="http://stevendkay.files.wordpress.com/2010/02/scotland-dots.png"><img src="http://stevendkay.files.wordpress.com/2010/02/scotland-dots.png?w=395&#038;h=383" alt="" title="scotland-dots" width="395" height="383" class="alignnone size-full wp-image-283" /></a></p>
<p>Now, you need to export the map from OpenStreetMap.</p>
<p>The corners have been set as follows..</p>
<p>&#8230; llcrnrlon=-8.0,llcrnrlat=54.5,urcrnrlon=1.5,urcrnrlat=59.5 &#8230;</p>
<p>llcrn stands for the lower-left coordinate, and and urcrn for the upper-right coordinate.</p>
<p>So if you if you export from OpenStreetMap using these coordinates&#8230;</p>
<p><a href="http://stevendkay.files.wordpress.com/2010/02/download.png"><img src="http://stevendkay.files.wordpress.com/2010/02/download.png?w=600&#038;h=315" alt="" title="download" width="600" height="315" class="alignnone size-full wp-image-285" /></a></p>
<p>.. you&#8217;ll have a map of Scotland with the Mercator projection.</p>
<p>The two images can then be composited in Photoshop or another graphics app like the Gimp.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=280&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/02/24/plotting-points-on-an-openstreetmap-export/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/02/scotland-pinboard.png" medium="image">
			<media:title type="html">flickr map of scotland</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/02/scotland-dots.png" medium="image">
			<media:title type="html">scotland-dots</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/02/download.png" medium="image">
			<media:title type="html">download</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a pinboard map of geotagged photos in a flickr pool</title>
		<link>http://stevendkay.wordpress.com/2010/01/14/creating-a-pinboard-map-of-geotagged-photos-in-a-flickr-pool/</link>
		<comments>http://stevendkay.wordpress.com/2010/01/14/creating-a-pinboard-map-of-geotagged-photos-in-a-flickr-pool/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 23:44:04 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Basemap]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[Flickr API]]></category>
		<category><![CDATA[Infovis]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Cartography]]></category>
		<category><![CDATA[geotagging]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[Mapping]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=267</guid>
		<description><![CDATA[using matplotlib and basemap to produce simple pinboard maps of geotagged photos in flickr groups<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=267&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://stevendkay.files.wordpress.com/2010/01/pgs-pinboard.png"><img src="http://stevendkay.files.wordpress.com/2010/01/pgs-pinboard.png?w=600&#038;h=622" alt="" title="pgs-pinboard" width="600" height="622" class="alignnone size-full wp-image-268" /></a></p>
<p>In this post I&#8217;ll show how to produce a simple pinboard map of geotagged photos in a flickr group pool, using Python and Basemap/Matplotlib. You&#8217;ll need:-</p>
<ul>
<li>Python</li>
<li><a href="http://stuvel.eu/projects/flickrapi">Beej&#8217;s Flickr API</a></li>
<li><a href="http://www.flickr.com/services/apps/create/apply">A flickr API key</a></li>
<li><a href="http://matplotlib.sourceforge.net/">Matplotlib</a></li>
<li><a href="http://matplotlib.sourceforge.net/basemap/doc/html/">Basemap</a></li>
</ul>
<p>There are two short scripts here:-</p>
<ul>
<li>A script to find the longitude and latitude of geotagged photos in the group pool</li>
<li>A script to generate the plot</li>
</ul>
<p>The first script produces a CSV file; the second uses this CSV file to produce the plot. </p>
<p>Here&#8217;s the script to produce the CSV file with photo locations:-</p>
<p><pre class="brush: python;">
# -*- coding: UTF8 -*-
'''
Created on 12 May 2009
Based on beejs flickr API
Produce a list of photo locations for a given
group's pool on flickr
@author: Steven Kay
'''

import flickrapi
import string
import datetime
import string
import time

# Enter your API key below
# You can apply for an API key at 
# http://www.flickr.com/services/apps/create/apply
api_key = '' 

# paste group NSID below
group = '1124494@N22'

# sample... fetch your latest images with 
# a count of the views, faves and comments

if __name__ == '__main__':
    flickr = flickrapi.FlickrAPI(api_key)
    response_photos = flickr.groups_pools_getPhotos(group_id=group,per_page=500,extras='geo')
    root=response_photos.findall('.//photos')
    pages=int(root[0].get('pages'))
    if pages&gt;8:
        # stop after 8 pages of 500 images
        # not sure if groups.pools.getPhotos has the same
        # 4000 image limit as photos.search..?
        pages=8
    
    fo=open(r&quot;C:\infoviz\scotland_photos.csv&quot;,&quot;w&quot;)
    print &quot;Longitude,Latitude&quot;
    fo.write(&quot;Longitude,Latitude\n&quot;)
    for page in range(0,pages):
        response_photos = flickr.groups_pools_getPhotos(group_id=group,per_page=500,page=str(page),extras='geo') 
        for photo in response_photos.findall(&quot;.//photos/photo&quot;):
            try:
                lat=photo.get('latitude')
                lon=photo.get('longitude')
                st=&quot;%s,%s&quot; %(lon,lat)
                if not st==&quot;0,0&quot;:
                    # ignore the odd buggy 0,0 coords
                    print &quot;%s,%s&quot; %(lon,lat)
                    fo.write(&quot;%s,%s\n&quot; %(lon,lat))
            except:
                pass
        time.sleep(1)
    fo.close()
</pre></p>
<p>You&#8217;ll need to find the NSID of the group as an input; you can find this with the flickr API call <a href="http://www.flickr.com/services/api/flickr.groups.search.html">flickr.group.search</a>. </p>
<p>Now, you have a simple CSV file with the latitude and longitude of each geotagged image in the pool.</p>
<p><pre class="brush: plain;">
Longitude,Latitude
-5.167792,58.352519
-4.024359,57.675544
-4.230251,57.497356
-4.2348,57.501045
-4.84703,56.646034
-4.306168,55.873986
-3.586263,56.564732
...
</pre></p>
<p>This demo uses the <a href="http://www.flickr.com/groups/photographyguidetoscotland/">Photography Guide to Scotland</a> pool.</p>
<p>The next step is to plot the map.</p>
<p><pre class="brush: python;">
'''
Simple Matplotlib/Basemap pinboard map for
Flickr Groups.

Need to provide a CSV file in following format

Longitude,Latitude
20.1,-3.25
20.225,-3.125
.. etc..

Created on 10 Oct 2009

@author: Steven Kay
'''

from basemap import Basemap 
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
import numpy as np
import string
import matplotlib.cm as cm

x=[] #longitudes
y=[] #latitudes

fi=open(r'C:\infoviz\scotland_photos.csv','r')

linenum=0
for line in fi:
    if linenum&gt;0:
        line=string.replace(line, &quot;\n&quot;,&quot;&quot;)
        try:
            fields=string.split(line,&quot;,&quot;)
            lon,lat=fields[0:2]
            x.append(float(lon))
            y.append(float(lat))
        except:
            pass
    linenum+=1
fi.close()

# cass projection centred on scotland
# will need to replace with a projection more suited
# to the group you're plotting

m = Basemap(llcrnrlon=-8.0,llcrnrlat=54.5,urcrnrlon=1.5,urcrnrlat=59.5,
            resolution='h',projection='cass',lon_0=-4.36,lat_0=54.5)
x1,y1=m(x,y)
m.drawmapboundary(fill_color='cyan') # fill to edge
m.drawcountries()
m.drawrivers() # you may want to turn this off for larger areas like continents
m.fillcontinents(color='white',lake_color='cyan',zorder=0)
m.scatter(x1,y1,s=5,c='r',marker=&quot;o&quot;,cmap=cm.jet,alpha=1.0)

plt.title(&quot;Photography Guide to Scotland in FlickR&quot;) # might want to change this!
plt.show()
</pre></p>
<p>This script uses a projection centred around scotland; you&#8217;ll need to change the following line&#8230;<br />
<pre class="brush: python;">
m = Basemap(llcrnrlon=-8.0,llcrnrlat=54.5,urcrnrlon=1.5,urcrnrlat=59.5,
            resolution='h',projection='cass',lon_0=-4.36,lat_0=54.5)
</pre><br />
&#8230;to something more suitable for your needs. Basemap provides an <a href="http://matplotlib.sourceforge.net/basemap/doc/html/users/mapsetup.html">intimidating list of projections </a>which should meet your needs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=267&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/01/14/creating-a-pinboard-map-of-geotagged-photos-in-a-flickr-pool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/01/pgs-pinboard.png" medium="image">
			<media:title type="html">pgs-pinboard</media:title>
		</media:content>
	</item>
		<item>
		<title>Processing Sketches</title>
		<link>http://stevendkay.wordpress.com/2010/01/11/processing-sketches/</link>
		<comments>http://stevendkay.wordpress.com/2010/01/11/processing-sketches/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 23:06:41 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Processing]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=249</guid>
		<description><![CDATA[I&#8217;ve been experimenting with the Processing Language recently. It&#8217;s quite addictive Here are a few tasters&#8230; click through to see the animation (needs Java) and the source. You can see the rest of my Processing portfolio on Openprocessing.org<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=249&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with the <a href="http://processing.org/">Processing Language</a> recently. It&#8217;s quite addictive <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here are a few tasters&#8230; click through to see the animation (needs Java) and the source.</p>
<p><a href="http://www.openprocessing.org/visuals/?visualID=6714"><img src="http://stevendkay.files.wordpress.com/2010/01/ripples.png?w=100&#038;h=100" alt="ripples processing sketch" title="ripples" width="100" height="100" class="alignnone size-full wp-image-253" /></a><br />
<a href="http://www.openprocessing.org/visuals/?visualID=6783"><img src="http://stevendkay.files.wordpress.com/2010/01/harmonograph1.png?w=100&#038;h=100" alt="" title="harmonograph" width="100" height="100" class="alignnone size-full wp-image-255" /></a><br />
<a href="http://www.openprocessing.org/visuals/?visualID=6656"><img src="http://stevendkay.files.wordpress.com/2010/01/worm.png?w=100&#038;h=100" alt="" title="worm" width="100" height="100" class="alignnone size-full wp-image-256" /></a></p>
<p>You can see the rest of my Processing portfolio on <a href="http://www.openprocessing.org/portal/?userID=3552">Openprocessing.org</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/249/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=249&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2010/01/11/processing-sketches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/01/ripples.png" medium="image">
			<media:title type="html">ripples</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/01/harmonograph1.png" medium="image">
			<media:title type="html">harmonograph</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2010/01/worm.png" medium="image">
			<media:title type="html">worm</media:title>
		</media:content>
	</item>
		<item>
		<title>world endangered species map</title>
		<link>http://stevendkay.wordpress.com/2009/10/25/world-endangered-species-map/</link>
		<comments>http://stevendkay.wordpress.com/2009/10/25/world-endangered-species-map/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 13:23:04 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Basemap]]></category>
		<category><![CDATA[Infovis]]></category>
		<category><![CDATA[Matplotlib]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/2009/10/25/world-endangered-species-map/</guid>
		<description><![CDATA[A map of Endangered Species worldwide by country<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=243&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin-left:10px;margin-bottom:10px;">
<a href="http://www.flickr.com/photos/stevefaeembra/4041949759/" title="photo sharing"><img src="http://farm4.static.flickr.com/3490/4041949759_0ae0b0d5cf_m.jpg" alt="" style="border:solid 2px #000000;" /></a><br />
<br />
<span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/stevefaeembra/4041949759/">world endangered species map</a><br />
<br />
Originally uploaded by <a href="http://www.flickr.com/people/stevefaeembra/">stevefaeembra</a><br />
</span>
</div>
<p>visualizing the number of endangered species worldwide. </p>
<p>Outer circle represents number of species in total; green inner circle is the proportion that are plant species.</p>
<p>sources of data &#8211; Guardian Data Blog. Country locations from CIA World Factbook. Plotted using python/matplotlib with baseline extension.<br /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=243&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2009/10/25/world-endangered-species-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3490/4041949759_0ae0b0d5cf_m.jpg" medium="image" />
	</item>
		<item>
		<title>unemployment statistics in the UK</title>
		<link>http://stevendkay.wordpress.com/2009/10/14/unemployment-statistics-in-the-uk/</link>
		<comments>http://stevendkay.wordpress.com/2009/10/14/unemployment-statistics-in-the-uk/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 23:59:39 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Basemap]]></category>
		<category><![CDATA[Infovis]]></category>
		<category><![CDATA[Infoviz]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/2009/10/14/unemployment-statistics-in-the-uk/</guid>
		<description><![CDATA[unemployment statistics in the UK Originally uploaded by stevefaeembra Visualizing recent trends in benefit claimant counts in the UK. Unemployment data from the Guardian Data Blog. Constituency coordinates courtesy of the TheyWorkForYou API. The three heatmaps show, respectively, from left to right:- (1) the %age change in those claiming benefits (hotspot in the Thames Valley) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=239&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin-left:10px;margin-bottom:10px;">
<a href="http://www.flickr.com/photos/stevefaeembra/4012700180/" title="photo sharing"><img src="http://farm3.static.flickr.com/2587/4012700180_f30e940d8f_m.jpg" alt="" style="border:solid 2px #000000;" /></a><br />
<br />
<span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/stevefaeembra/4012700180/">unemployment statistics in the UK</a><br />
<br />
Originally uploaded by <a href="http://www.flickr.com/people/stevefaeembra/">stevefaeembra</a><br />
</span>
</div>
<p>Visualizing recent trends in benefit claimant counts in the UK. </p>
<p>Unemployment data from the Guardian Data Blog.</p>
<p>Constituency coordinates courtesy of the TheyWorkForYou API.</p>
<p>The three heatmaps show, respectively, from left to right:-</p>
<p>(1) the %age change in those claiming benefits (hotspot in the Thames Valley)</p>
<p>(2) the %age of the workforce out of work and claiming benefits (hotspots in the Midlands, Hull, London, Liverpool, Glasgow)</p>
<p>(3) the gender ratio of claimant percentages. Red=higher ratio of male to female claimants, blue=lower ratio of male to female claimants<br /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/239/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=239&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2009/10/14/unemployment-statistics-in-the-uk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2587/4012700180_f30e940d8f_m.jpg" medium="image" />
	</item>
		<item>
		<title>homicide rates</title>
		<link>http://stevendkay.wordpress.com/2009/10/13/homicide-rates/</link>
		<comments>http://stevendkay.wordpress.com/2009/10/13/homicide-rates/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 22:40:40 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[flickr]]></category>
		<category><![CDATA[Image Processing]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Basemap]]></category>
		<category><![CDATA[Infovis]]></category>
		<category><![CDATA[Infoviz]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/2009/10/13/homicide-rates/</guid>
		<description><![CDATA[homicide rates Originally uploaded by stevefaeembra A visualisation of the homicide rates across the world.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=235&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin-left:10px;margin-bottom:10px;">
<a href="http://www.flickr.com/photos/stevefaeembra/4009056203/" title="photo sharing"><img src="http://farm3.static.flickr.com/2646/4009056203_ebacf5cbec_m.jpg" alt="" style="border:solid 2px #000000;" /></a><br />
<br />
<span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/stevefaeembra/4009056203/">homicide rates</a><br />
<br />
Originally uploaded by <a href="http://www.flickr.com/people/stevefaeembra/">stevefaeembra</a><br />
</span>
</div>
<p>A visualisation of the homicide rates across the world.<br /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=235&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2009/10/13/homicide-rates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2646/4009056203_ebacf5cbec_m.jpg" medium="image" />
	</item>
		<item>
		<title>Scatter plots with Basemap and Matplotlib</title>
		<link>http://stevendkay.wordpress.com/2009/10/12/scatter-plots-with-basemap-and-matplotlib/</link>
		<comments>http://stevendkay.wordpress.com/2009/10/12/scatter-plots-with-basemap-and-matplotlib/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 21:54:02 +0000</pubDate>
		<dc:creator>stevendkay</dc:creator>
				<category><![CDATA[flickr]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Basemap]]></category>
		<category><![CDATA[Cartography]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[geotag]]></category>
		<category><![CDATA[Infoviz]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[projection]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Vizualization]]></category>

		<guid isPermaLink="false">http://stevendkay.wordpress.com/?p=222</guid>
		<description><![CDATA[Tutorial to produce scatter plots with the Basemap matplotlib extension.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=222&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://stevendkay.files.wordpress.com/2009/10/flickr-geotagging-with-base.png?w=600&#038;h=600" alt="flickr-geotagging-with-base" title="flickr-geotagging-with-base" width="600" height="600" class="alignnone size-full wp-image-225" /><br />
A while back I used the flickr api to map 24 hours worth of geotagged photos.</p>
<p>My previous attempts needed some manual Photoshop work to superimpose the plots on a map. The next logical step is to do the whole process &#8211; from start to finish &#8211; in code, and remove the manual steps.</p>
<p>To do this, I tried the awesome <a href="http://matplotlib.sourceforge.net/basemap/doc/html/index.html">Basemap</a> toolkit. This library allows all sorts of cartographic projections&#8230;</p>
<p><strong>Installing Basemap</strong></p>
<p>Basemap is an extention available with Matplotlib. You can download it <a href="http://sourceforge.net/projects/matplotlib/files/">here</a> (under matplotlib-toolkits)</p>
<p>I installed the version for Python 2.5 on Windows; this missed out a dependency to httplib2 which I needed to install separately from <a href="http://code.google.com/p/httplib2/">here</a>. </p>
<p><strong>Getting started</strong></p>
<p>Let&#8217;s assume you have 3 arrays &#8211; x, y and z. These contain the longitudes, latitudes, and data values at each point. In this case, I binned the geotagged photos into a grid of degree points (360&#215;180), so that each degree square contained the number of photos tagged in that degree square.</p>
<p><strong>Setting up</strong></p>
<p><pre class="brush: python;">
from basemap import Basemap 
import matplotlib.pyplot as plt
import numpy as np
import string
import matplotlib.cm as cm

x=[]
y=[]
z=[]
</pre></p>
<p>Now, you need to populate the x,y and z arrays with values. I&#8217;ll leave that an exercise to you <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  All three arrays need to be the same length. </p>
<p>Now, you need to decide which projection to use. Here, I&#8217;ve used the Orthographic projection.</p>
<p><pre class="brush: python;">
m = Basemap(projection='ortho',lon_0=-50,lat_0=60,resolution='l')
</pre></p>
<p>Here is the secret sauce I took a while to work out. That&#8217;ll teach me not to R the FM. This line transforms all the lat, lon coordinates into the appropriate projection.</p>
<p><pre class="brush: python;">
x1,y1=m(x,y)
</pre></p>
<p>The next bit, you can decide which bits you want to plot &#8211; land masses, country boundaries etc.</p>
<p><pre class="brush: python;">
m.drawmapboundary(fill_color='black') # fill to edge
m.drawcountries()
m.fillcontinents(color='white',lake_color='black',zorder=0)
</pre></p>
<p>Finally, the scatter plot.</p>
<p><pre class="brush: python;">
m.scatter(x1,y1,s=sizes,c=cols,marker=&quot;o&quot;,cmap=cm.cool,alpha=0.7)
plt.title(&quot;Flickr Geotagging Counts with Basemap&quot;)
plt.show()
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/stevendkay.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/stevendkay.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/stevendkay.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=stevendkay.wordpress.com&amp;blog=9341754&amp;post=222&amp;subd=stevendkay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://stevendkay.wordpress.com/2009/10/12/scatter-plots-with-basemap-and-matplotlib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9c6ba8e5d321f49eca08d1f6cfa3b338?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">stevendkay</media:title>
		</media:content>

		<media:content url="http://stevendkay.files.wordpress.com/2009/10/flickr-geotagging-with-base.png" medium="image">
			<media:title type="html">flickr-geotagging-with-base</media:title>
		</media:content>
	</item>
	</channel>
</rss>
