<?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>Spatial Analysis &#187; R</title>
	<atom:link href="http://spatialanalysis.co.uk/tag/r/feed/" rel="self" type="application/rss+xml" />
	<link>http://spatialanalysis.co.uk</link>
	<description>Spatial data visualisation, analysis and resources</description>
	<lastBuildDate>Tue, 15 May 2012 13:21:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Mapped: British, Spanish and Dutch Shipping 1750-1800</title>
		<link>http://spatialanalysis.co.uk/2012/03/mapped-british-shipping-1750-1800/</link>
		<comments>http://spatialanalysis.co.uk/2012/03/mapped-british-shipping-1750-1800/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 13:04:21 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Featured Maps]]></category>
		<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[maptools]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://spatialanalysis.co.uk/?p=3533</guid>
		<description><![CDATA[I recently stumbled upon a fascinating dataset which contains digitised information from the log books of ships (mostly from Britain, France, Spain and The Netherlands) sailing between 1750 and 1850. The creation of this dataset was completed as part of the Climatological Database for the World&#8217;s Oceans 1750-1850 (CLIWOC) project. The routes are plotted from the ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/shipping_1750_1800.png"><img class="alignnone  wp-image-3534" title="shipping_1750_1800" src="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/shipping_1750_1800-1024x494.png" alt="" width="614" height="296" /></a></p>
<p>I recently stumbled upon a <a href="http://www.ucm.es/info/cliwoc/cliwoc15.htm" target="_blank">fascinating dataset</a> which contains digitised information from the log books of ships (mostly from Britain, France, Spain and The Netherlands) sailing between 1750 and 1850. The creation of this dataset was completed as part of the<a href="http://www.ucm.es/info/cliwoc/" target="_blank"> Climatological Database for the World&#8217;s Oceans</a> 1750-1850 (CLIWOC) project. The routes are plotted from the lat/long positions derived from the ships&#8217; logs. I have played around with the original data a little to clean it up (I removed routes where there was a gap of over 1000km between known points, and only mapped to the year 1800). As you can see the British (above) and Spanish and Dutch (below) had very different trading priorities over this period. What fascinates me most about these maps is the thousands (if not millions) of man hours required to create them. Today we churn out digital spatial information all the time without thinking, but for each set of coordinates contained in these maps a ship and her crew had to sail there and someone had to work out a location without GPS or reliable charts.</p>
<p><a href="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/Spain_shipping.png"><img class="alignnone  wp-image-3540" title="Spain_shipping" src="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/Spain_shipping-1024x508.png" alt="" width="614" height="305" /></a></p>
<p><a href="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/dutch_shipping1750_1800.png"><img class="alignnone  wp-image-3558" title="dutch_shipping1750_1800" src="http://spatialanalysis.co.uk/wp-content/uploads/2012/03/dutch_shipping1750_1800-1024x509.png" alt="" width="614" height="305" /></a></p>
<p>These maps were produced with the latest version of <a href="http://www.r-project.org/">R</a>&#8216;s <a href="http://had.co.nz/ggplot2/" target="_blank">ggplot2</a>, <a href="http://cran.r-project.org/web/packages/maptools/index.html" target="_blank">maptools</a>, <a href="http://cran.r-project.org/web/packages/geosphere/index.html" target="_blank">geosphere</a> and <a href="http://cran.r-project.org/web/packages/png/index.html" target="_blank">png</a> packages. Formatting the data took the most work (it was a very large MS Access database). I used ggplot&#8217;s annotation_raster() to add the compass rose and title.</p>
<p>Update: For some nice animations and a much better critical analysis of the data see <a href="http://sappingattention.blogspot.co.uk/2012/04/visualizing-ocean-shipping.html" target="_blank">Ben Schmidts blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2012/03/mapped-british-shipping-1750-1800/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Great Maps with ggplot2</title>
		<link>http://spatialanalysis.co.uk/2012/02/great-maps-ggplot2/</link>
		<comments>http://spatialanalysis.co.uk/2012/02/great-maps-ggplot2/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 13:02:15 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cycle]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[lineend]]></category>
		<category><![CDATA[London]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://spatialanalysis.co.uk/?p=3455</guid>
		<description><![CDATA[The above map (and this one) was produced using R and ggplot2 and serve to demonstrate just how sophisticated R visualisations can be. We are used to seeing similar maps produced with conventional GIS platforms or software such as Processing but I hadn&#8217;t yet seen one from the R community (feel free to suggest some ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://spatialanalysis.co.uk/wp-content/uploads/2012/02/bike_ggplot.png"><img class="alignnone  wp-image-3456" title="bike_ggplot" src="http://spatialanalysis.co.uk/wp-content/uploads/2012/02/bike_ggplot-1024x676.png" alt="" width="553" height="365" /></a></p>
<p>The above map (<a href="http://spatialanalysis.co.uk/2012/02/london-cycle-hire-pollution/" target="_blank">and this one</a>) was produced using R and <a href="http://had.co.nz/ggplot2/" target="_blank">ggplot2</a> and serve to demonstrate just <a href="http://spatialanalysis.co.uk/2012/01/coming-age-spatial-data-visualisation/" target="_blank">how sophisticated</a> R visualisations can be. We are used to seeing similar maps produced with conventional GIS platforms or software such as <a href="http://processing.org/" target="_blank">Processing</a> but I hadn&#8217;t yet seen one from the R community (feel free to suggest some in the comments). The map contains three layers: buildings, water and the journey segments. The most challenging aspect was to change the standard line ends in <a href="http://had.co.nz/ggplot2/geom_segment.html" target="_blank">geom_segment</a> from &#8220;butt&#8221; to &#8220;round&#8221; in order that the lines appeared continuous and not with &#8220;cracks&#8221; in, see below.</p>
<p><a href="http://spatialanalysis.co.uk/wp-content/uploads/2012/02/lineend.png"><img class="alignnone size-full wp-image-3459" title="lineend" src="http://spatialanalysis.co.uk/wp-content/uploads/2012/02/lineend.png" alt="" width="553" height="288" /></a></p>
<p>I am grateful to Hadley and the rest of the ggplot2 Google Group for the solution. You can see it <a href="http://groups.google.com/group/ggplot2/browse_thread/thread/9a8befd1ffcc4ae6" target="_blank">here</a>. From this point I layered the plots using the <a href="http://had.co.nz/ggplot2/geom_polygon.html" target="_blank">geom_polygon()</a> command for the buildings and water bodies and my new function geom_segment2() for the journey segments- these were simply the start and end latitudes and longitudes for each node in the road network and the number of times a cyclist passed between them. I have included the code below<br />
&nbsp;</p>
<p><code><br />
#Code supplied by james cheshire Feb 2012<br />
#load packages and enter development mode<br />
library('devtools')<br />
dev_mode()<br />
library(ggplot2)<br />
library(proto)</p>
<p>#if your map data is a shapefile use maptools<br />
library(maptools)<br />
gpclibPermit()</p>
<p>#create GeomSegment2 function<br />
GeomSegment2 <- proto(ggplot2:::GeomSegment, {<br />
 objname <- "geom_segment2"<br />
 draw <- function(., data, scales, coordinates, arrow=NULL, ...) {<br />
  if (is.linear(coordinates)) {<br />
    return(with(coord_transform(coordinates, data, scales),<br />
      segmentsGrob(x, y, xend, yend, default.units="native",<br />
      gp = gpar(col=alpha(colour, alpha), lwd=size * .pt,<br />
        lty=linetype, lineend = "round"),<br />
      arrow = arrow)<br />
    ))<br />
  }<br />
}})</p>
<p>geom_segment2 <- function(mapping = NULL, data = NULL, stat =<br />
"identity", position = "identity", arrow = NULL, ...)  {<br />
 GeomSegment2$new(mapping = mapping, data = data, stat = stat,<br />
       position = position, arrow = arrow, ...)<br />
}</p>
<p>#load data stlat/stlong are the start points elat/elong are the end points of the lines<br />
lon<- read.csv("bikes_london.csv", header=F, sep=";")<br />
names(lon)<-c("stlat", "stlon", "elat", "elong", "count")</p>
<p>#load spatial data. You need to fortify if loaded as a shapefile<br />
water<- fortify(readShapePoly("waterfeatures.shp"))<br />
built<- fortify(readShapePoly("buildings.shp"))</p>
<p>#This step removes the axes labels etc when called in the plot.<br />
xquiet<- scale_x_continuous("", breaks=NA)<br />
yquiet<-scale_y_continuous("", breaks=NA)<br />
quiet<-list(xquiet, yquiet)</p>
<p>#create base plot<br />
plon1<- ggplot(lon, aes(x=stlon, y=stlat))</p>
<p>#ready the plot layers<br />
pbuilt<-c(geom_polygon(data=built, aes(x=long, y=lat, group=group), colour= "#4B4B4B", fill="#4F4F4F", lwd=0.2))<br />
pwater<-c(geom_polygon(data=water, aes(x=long, y=lat, group=group), colour= "#708090", fill="#708090"))</p>
<p>#create plot<br />
plon2<- plon1 +pbuilt+ pwater+ geom_segment2(aes(xend=elong, yend=elat, size= count, colour=count))+scale_size(range=c(0.06, 1.8))+scale_colour_gradient(low="#FFFFFF", high="#FFFF33", space="rgb")+coord_equal(ratio=1/cos(lon$elat[1]*pi/180))+quiet+ opts(panel.background=theme_rect(fill="#404040"))</p>
<p>plon2<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2012/02/great-maps-ggplot2/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Coming of Age: R and Spatial Data Visualisation</title>
		<link>http://spatialanalysis.co.uk/2012/01/coming-age-spatial-data-visualisation/</link>
		<comments>http://spatialanalysis.co.uk/2012/01/coming-age-spatial-data-visualisation/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 14:45:57 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[dataviz]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[spatial data]]></category>

		<guid isPermaLink="false">http://spatialanalysis.co.uk/?p=3354</guid>
		<description><![CDATA[I have been using R (a free statistics and graphics software package) now for the past four years or so and I have seen it become an increasingly powerful method of both analysing and visualising spatial data. Crucially, more and more people are writing accessible tutorials (see here) for beginners and intermediate users and the development ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://spatialanalysis.co.uk/2011/03/global-migration-maps/"><img class="alignnone  wp-image-2317" title="global_migration_sm" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/03/global_migration_sm1-1024x430.png" alt="" width="553" height="232" /></a></p>
<p>I have been using <a href="http://www.r-project.org/" target="_blank">R </a>(a free statistics and graphics software package) now for the past four years or so and I have seen it become an increasingly powerful method of both analysing and visualising spatial data. Crucially, more and more people are writing accessible tutorials (<a href="http://spatialanalysis.co.uk/r/" target="_blank">see here</a>) for beginners and intermediate users and the development of packages such as <a href="http://had.co.nz/ggplot2/" target="_blank">ggplot2</a> have made it simpler than ever to produce fantastic graphics. You don&#8217;t get the interactivity you would with conventional GIS software such as ArcGIS when you produce the visualisation but you are much more flexible in terms of the combinations of plot types and the ease with which they can be combined. It is, for example, <a href="http://mappingcenter.esri.com/index.cfm?fa=ask.answers&amp;q=2199" target="_blank">time consuming</a> to produce multivariate symbols (such as those varying in size and colour) in <a href="http://www.esri.com/" target="_blank">ArcGIS</a> but with R it is as simple* as one line of code. I have, for example, been able to add subtle transitions in the lines of the migration map above.  Unless you have massive files, plotting happens quickly and can be easily saved to vector formats for tweaking in a graphics package.</p>
<p><a href="http://spatialanalysis.co.uk/2011/10/mapping-academic-tweets/"><img class="alignnone  wp-image-3075" title="journal_tweets_point" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/10/journal_tweets_point-1024x483.png" alt="" width="553" height="261" /></a></p>
<p>R&#8217;s utilisation has been tempered by its relatively sparse documentation and challenging usability. The R community is increasingly aware of this with packages such as <a href="http://blog.fellstat.com/?p=89" target="_blank">DeducerSpatial </a>providing a graphical user interface to some of R&#8217;s spatial data functionality. More and more tutorials are appearing and people have been inspired by some high profile maps made with R (<a href="http://www.facebook.com/note.php?note_id=469716398919" target="_blank">see here</a>) so I am confident that it will be increasingly seen as the engine for slightly glossier analysis and visualisation packages.</p>
<p><a href="http://spatialanalysis.co.uk/2011/02/mapping-londons-population-change-2011-2030/"><img class="alignnone  wp-image-2205" title="london_pop_change" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/02/london_pop_change1.png" alt="" width="541" height="371" /></a></p>
<p>R can&#8217;t do everything- I find handling map projections a bit tricky and its not possible to pan and zoom the maps as they are being created. In some circumstances I can&#8217;t do without these functions so I opt for a traditional GIS. Also, for the programmers out there used to the likes of <a href="http://python.org/" target="_blank">Python</a> and <a href="http://docs.oracle.com/javase/tutorial/" target="_blank">Java</a>, R can have quite a few quirks in its syntax so be patient. Despite it&#8217;s flaws, if you have a large data processing and visualisation task R is a great option. It offers a high degree of flexibility in terms of input data formats and with packages such as <a href="http://cran.r-project.org/web/packages/twitteR/" target="_blank">twitteR</a>, <a href="http://cran.r-project.org/web/packages/RCurl/index.html" target="_blank">RCurl</a>, and <a href="http://cran.r-project.org/web/packages/XML/index.html" target="_blank">XML</a> it is easier than ever to import online data sources from social media sites and data feeds.  Aside from traditional export formats for the visualisations it has become incredibly simple to export interactive and animated graphics using the <a href="http://spatialanalysis.co.uk/2011/01/r-interface-to-google-chart-tools/" target="_blank">googleVIS</a> package or <a href="http://igraph.sourceforge.net/" target="_blank">igraph</a> for network visualisations. Such flexibility is invaluable if you are seeking to create a variety of different graphics from a single datasource without having to format it for multiple software packages. The great thing with R is the sense that it still has masses of unrealised potential for  future spatial data visualizations. If you know of any good visualisations or tutorials please leave a comment!</p>
<p>I should also say that if you would like to learn how to do these sorts of visualisations (and more!) come and do our <a href="http://www.bartlett.ucl.ac.uk/casa/programmes/postgraduate/mres-advanced-spatial-analysis-visualisation">masters course</a>!</p>
<p><em>*simple might be a slightly optimistic way of thinking about it if you haven&#8217;t used R before, but with a <a href="http://spatialanalysis.co.uk/r/" target="_blank">bit of practice</a> you will ge there! </em></p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2012/01/coming-age-spatial-data-visualisation/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Global Migration Maps</title>
		<link>http://spatialanalysis.co.uk/2011/03/global-migration-maps/</link>
		<comments>http://spatialanalysis.co.uk/2011/03/global-migration-maps/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 13:53:21 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Popular]]></category>
		<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=2296</guid>
		<description><![CDATA[&#160; Migrations of people have existed for millennia and occur at a range of scales and time-periods (from small-scale journeys to work through to intercontinental resettlement). As a geographer I have long been interested in these and thought it was about time I mapped them! Using data from the Global Migrant Origin Database (thanks Adam for the ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2011/03/global_migration_sm1.png" class="img zoom" title="Global Migration"><img src="http://spatialanalysis.co.uk/wp-content/themes/theme-unite/includes/timthumb.php?src=/wp-content/uploads/2011/03/global_migration_sm1.png&amp;w=580&amp;h=246&amp;zc=1" width="580" height="246" alt="Global Migration" /></a></p>
<p>&nbsp;</p>
<p style="text-align: left;">Migrations of people have existed for millennia and occur at a range of scales and time-periods (from small-scale journeys to work through to intercontinental resettlement). As a geographer I have long been interested in these and thought it was about time I mapped them! Using data from the <a href="http://www.migrationdrc.org/research/typesofmigration/global_migrant_origin_database.html" target="_blank">Global Migrant Origin Database</a> (thanks <a href="http://adamdennett.co.uk/blog/" target="_blank">Adam</a> for the tip) and <a href="http://www.r-project.org/" target="_blank">R</a>, my favourite stats software, I have produced the maps you see here (click on them for higher resolution). Each line shows the origins and destinations of at least 4000 people in a given year (2000 in this case). The more red the line the more people it represents. I have used<a href="http://en.wikipedia.org/wiki/Great_circle" target="_blank"> great circle distance</a> to plot them onto the Earth.  The map below shows the same magnitude of flows but just for Europe. The Earth has been flattened for this one so the flows are represented by arbitrary arcs.</p>
<div style="margin: 0 auto; width: 334px;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2011/03/european_migration_sm1.png" class="img zoom" title="image"><img src="http://spatialanalysis.co.uk/wp-content/themes/theme-unite/includes/timthumb.php?src=/wp-content/uploads/2011/03/european_migration_sm1.png&amp;w=334&amp;h=374&amp;zc=1" width="334" height="374" alt="image" /></a></div>
<p>&nbsp;</p>
<p style="text-align: left;">These visualisations aren&#8217;t perfect. Firstly they are based on a dataset where many of the movements are best guesses rather than measured data. You can read more about this <a href="http://econ.worldbank.org/external/default/main?pagePK=64165259&amp;piPK%20=64165421&amp;theSitePK=469372&amp;menuPK=64166093&amp;entityID=000016406_20070306151900" target="_blank">here</a>. It would also be great to have actual flows rather than inferred flows based on the number of migrants in each country. If I made these maps again I might draw lines between capital cities or population centres to avoid the impression that the majority of migrations to/ from Russia start/end in Siberia for example. There are of course endless ways of partitioning the data/ selecting the colours. Despite this I am really pleased with effect and the maps go some way to showing the dynamism in many 21st Century populations.</p>
<p style="text-align: left;"><strong>Technical Details</strong></p>
<p style="text-align: left;">I think <a href="http://paulbutler.org/archives/visualizing-facebook-friends/">Paul Butler&#8217;s Facebook Map</a> threw down the gauntlet to the R community in terms of the quality of visualisations that can be produced with the software so I was keen to see what I could do. To produce the maps I calculated the great circle distances using the <a href="http://cran.r-project.org/web/packages/geosphere/index.html">geosphere</a> package, I calculated my own arcs for the second map and used the <a href="http://cran.r-project.org/web/packages/maps/index.html">maps</a> package for my World outline. The visualisations (including projections) were done using <a href="http://had.co.nz/ggplot2/">ggplot2</a>. Over the next few months I plan to stick together a more complete tutorial (PhD write-up permitting!).**UPDATE** the flowingdata blog has beaten me to it see <a href="http://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2011/03/global-migration-maps/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Mapping London&#8217;s Population Change 1801-2030</title>
		<link>http://spatialanalysis.co.uk/2011/02/mapping-londons-population-change-2011-2030/</link>
		<comments>http://spatialanalysis.co.uk/2011/02/mapping-londons-population-change-2011-2030/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 10:34:20 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Britain]]></category>
		<category><![CDATA[Featured Maps]]></category>
		<category><![CDATA[London]]></category>
		<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[london datastore]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[opendata]]></category>
		<category><![CDATA[Population]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[R Maps]]></category>
		<category><![CDATA[R spatial]]></category>
		<category><![CDATA[RColorBrewer]]></category>
		<category><![CDATA[rspatialtips]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=2200</guid>
		<description><![CDATA[Buried in the London Datastore are the population estimates for each of the London Boroughs between 2001 &#8211; 2030. They predict a declining population for most boroughs with the exception of a few to the east. I was surprised by this general decline and also the numbers involved- I expected larger changes from one year to ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2011/02/london_pop_change1.png"><img class="aligncenter size-full wp-image-2205" title="london_pop_change" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/02/london_pop_change1.png" alt="" width="601" height="412" /></a></p>
<p style="text-align: left;">Buried in the <a href="http://data.london.gov.uk/" target="_blank">London Datastore</a> are the <a href="http://data.london.gov.uk/datastore/package/gla-population-projections-2009-round-revised-shlaa-borough-sya" target="_blank">population estimates</a> for each of the <a href="http://en.wikipedia.org/wiki/London_borough" target="_blank">London Boroughs</a> between 2001 &#8211; 2030. They predict a declining population for most boroughs with the exception of a few to the east. I was surprised by this general decline and also the numbers involved- I expected larger changes from one year to the next. I think this is because my perception of migration is of the volume of people moving rather than the net effects on the baseline population of these movements. I don&#8217;t envy the <a href="http://www.london.gov.uk/" target="_blank">GLA</a> for making <a href="http://data.london.gov.uk/datastore/package/gla-population-projections-2009-round-revised-shlaa-borough-sya" target="_blank">predictions</a> so far into the future, but can understand why they have to do it (think how long it took initiate <a href="http://en.wikipedia.org/wiki/Crossrail" target="_blank">Crossrail</a>!). Last year I produced a simple animation showing past changes in London&#8217;s population density (<a href="http://data.london.gov.uk/datastore/package/historic-census-population" target="_blank">data</a>) and it provides a nice comparison to the above. In total I have squeezed 40 maps on this page!</p>
<p style="text-align: left;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2010/01/london_pop_density.gif"><img class="aligncenter size-full wp-image-534" title="london_pop_density" src="http://spatialanalysis.co.uk/wp-content/uploads/2010/01/london_pop_density.gif" alt="" width="600" height="400" /></a></p>
<h3>Technical Stuff</h3>
<p>These maps were all produced to demonstrate the mapping capabilities of <a href="http://www.r-project.org/" target="_blank">R</a>. The first uses <a href="http://had.co.nz/ggplot2/" target="_blank">ggplot2</a> (plus <a href="http://cran.r-project.org/web/packages/classInt/index.html" target="_blank">classInt</a> + <a href="http://cran.r-project.org/web/packages/RColorBrewer/index.html" target="_blank">RColorBrewer</a>) and is based on some <a href="https://bitbucket.org/markbulling/open-source/src/ded7d7392a5c/London%20Immigration.R" target="_blank">code</a> (see below) written by <a href="http://dotlinking.blogspot.com/" target="_blank">Mark Bulling</a>. If you follow the code below you will end up with<a href="http://www.flickr.com/photos/everheardofaspacebar/4259967972/in/photostream/" target="_blank"> this map</a>, not the one I have produced above. I will stick my code in a formal tutorial soon. The animation uses the standard plot functions (plus spatial packages) in R as per this <a href="http://rspatialtips.org.uk/2011/01/19/r-maps/" target="_blank">example</a>.<br />
<script type="text/javascript" src="https://bitbucket.org/markbulling/open-source/src/ded7d7392a5c/London%20Immigration.R?embed=t"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2011/02/mapping-londons-population-change-2011-2030/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>R interface to Google Chart Tools</title>
		<link>http://spatialanalysis.co.uk/2011/01/r-interface-to-google-chart-tools/</link>
		<comments>http://spatialanalysis.co.uk/2011/01/r-interface-to-google-chart-tools/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 09:54:03 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Gapminder]]></category>
		<category><![CDATA[Hans Rosling]]></category>
		<category><![CDATA[Income]]></category>
		<category><![CDATA[Life Expectancy]]></category>
		<category><![CDATA[Population]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[R spatial]]></category>
		<category><![CDATA[rspatialtips]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=1882</guid>
		<description><![CDATA[Hans Rosling eat your heart out! It is now possible to interface R statistics software to Google’s Gapminder inspired Chart Tools. The plots below were produced using the googleVis R package and three datasets from the Gapminder website. The first shows the relationship between income, life expectancy and population for 20 countries with the highest ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Hans_Rosling">Hans Rosling</a> eat your heart out! It is now possible to interface <a href="http://www.r-project.org/" target="_blank">R</a> statistics software to Google’s <a href="http://www.gapminder.org/" target="_blank">Gapminder</a> inspired <a href="http://code.google.com/apis/visualization/documentation/gallery.html" target="_blank">Chart Tools</a>. The plots below were produced using the <a href="http://cran.r-project.org/web/packages/googleVis/index.html" target="_blank">googleVis</a> R package and three datasets from the <a href="http://www.gapminder.org/" target="_blank">Gapminder</a> website. The first shows the relationship between income, life expectancy and population for 20 countries with the highest life expectancy in 1979 and the bottom plot shows the countries with the lowest 1979 life expectancy. Press play to see how the countries have faired over the past 50 years. You can also change the variables represented on each axes, the colours and the variable that controls the size of the bubbles.<br />
<script type="text/javascript" src="http://www.google.com/jsapi">// <![CDATA[</p>
<p>// ]]&gt;</script><br />
<script type="text/javascript" src="http://splintmap.geog.ucl.ac.uk/~james/googlevis.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<div id="MotionChart_2011-01-10-10-16-25"></div>
<p>Data: all_date, Chart ID: MotionChart_2011-01-10-10-16-25</p>
<p>R version 2.12.1 (2010-12-16),<br />
<a href="http://code.google.com/apis/visualization/terms.html"><br />
Google Terms of Use</a></p>
<p><script type="text/javascript" src="http://www.google.com/jsapi">// <![CDATA[</p>
<p>// ]]&gt;</script><br />
<script type="text/javascript" src="http://splintmap.geog.ucl.ac.uk/~james/googlevis2.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<div id="MotionChart_2011-01-10-10-10-46"></div>
<p>Data: all_date, Chart ID: MotionChart_2011-01-10-10-10-46</p>
<p>R version 2.12.1 (2010-12-16),<br />
<a href="http://code.google.com/apis/visualization/terms.html"><br />
Google Terms of Use</a></p>
<p>It was a bit fiddly to get the data formatted correctly and I couldn’t manage to get the complete dataset in one plot because my browser kept crashing (Chrome is best). Even with these teething problems it is a great way to get people creating better visualizations with their data. If you want to see Hans Rosling demonstrating these plots with his trademark enthusiasm I thoroughly recommend “The Joy of Stats” a program produced for the BBC. <a href="http://www.gapminder.org/videos/the-joy-of-stats/" target="_blank">You can watch it here</a>.</p>
<p>For those who want to create their own plots, I’m not proud of the code I used to format the data above so to get you started try this example (provided with the package).</p>
<p>library(googleVis)</p>
<p>data(Fruits)</p>
<p>M1 &lt;- gvisMotionChart(Fruits, idvar=&#8221;Fruit&#8221;, timevar=&#8221;Year&#8221;)</p>
<p>plot(M1)</p>
<p>Thanks to the <a href="http://r-ecology.blogspot.com/2011/01/r-and-google-visualization-api.html" target="_blank">Recology</a> blog for promoting this.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2011/01/r-interface-to-google-chart-tools/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Boris Bikes/Barclays Cycle Hire Average Journey Times</title>
		<link>http://spatialanalysis.co.uk/2011/01/boris-bikesbarclays-cycle-hire-average-journey-times/</link>
		<comments>http://spatialanalysis.co.uk/2011/01/boris-bikesbarclays-cycle-hire-average-journey-times/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 00:55:57 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Featured Maps]]></category>
		<category><![CDATA[London]]></category>
		<category><![CDATA[Visualisation]]></category>
		<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[barclays cycle]]></category>
		<category><![CDATA[borisbike]]></category>
		<category><![CDATA[Geography]]></category>
		<category><![CDATA[Interests]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[R Maps]]></category>
		<category><![CDATA[TFL]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=1830</guid>
		<description><![CDATA[The visualisation above shows the average relative duration of Boris Bikers&#8217; weekday journeys over a 4 month period at hourly intervals. For each time step the average journey time (in seconds) from each docking station has been calculated.This information is interesting because it shows the preference for short journeys around the City of London, whilst ...]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/18513391" width="500" height="281" frameborder="0"></iframe></p>
<p>The visualisation above shows the average relative duration of Boris Bikers&#8217; <strong>weekday</strong> journeys over a 4 month period at hourly intervals. For each time step the average journey time (in seconds) from each docking station has been calculated.This information is interesting because it shows the preference for short journeys around the City of London, whilst people on the outskirts of the the scheme (especially to the west) take longer journeys. I also like the the fact that journey times around Soho and the West End are longest around 23:00- perhaps correlating with the number of after-work drinks consumed. In one visualisation you get to see the changes in the cyclists behaviour- from the early morning commuters through to the late night cruisers</p>
<p>The data come from <a href="http://www.tfl.gov.uk/">Transport for London&#8217;s </a>recent release of 1.4 million Barclays Cycle Hire journeys to their <a href="http://www.tfl.gov.uk/businessandpartners/syndication/default.aspx">developers area</a> (thanks to this <a href="http://www.whatdotheyknow.com/request/one_million_barclays_cycle_hire">FOI request</a>). The data are said include all the journeys between 30 July 2010 and 3 November 2010, except those starting between midnight and 6am. In this analysis journeys taking more than one hour are not included (there are relatively few and many were actually the bikes being removed for maintenance) and docking stations with fewer than 10 journeys within each hour across the time period have also been ignored.</p>
<p>The maps can be improved in many ways- stay tuned for more developments and I will also post something a bit more technical about the methods I used etc to create the map (I used a strange cocktail of <a href="http://www.r-project.org/" target="_blank">R</a> and <a href="http://www.esri.com/software/arcgis/arcgis10/index.html" target="_blank">ArcGIS 10</a>) .</p>
<p>I also recommend Ollie O&#8217;Brien&#8217;s (@oobr) brilliant interactive <a href="http://oliverobrien.co.uk/2011/01/bikesharejourneys/" target="_blank">visualisations</a> these data.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2011/01/boris-bikesbarclays-cycle-hire-average-journey-times/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Exporting KML from R</title>
		<link>http://spatialanalysis.co.uk/2011/01/exporting-kml-from-r/</link>
		<comments>http://spatialanalysis.co.uk/2011/01/exporting-kml-from-r/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 23:03:54 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[R Maps]]></category>
		<category><![CDATA[R spatial]]></category>
		<category><![CDATA[rspatialtips]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=1789</guid>
		<description><![CDATA[Google Earth has become a popular way of disseminating spatial data. KML is the data format required to do this. It is possible to load almost any type of spatial data format into R and export it as a KML file. In my experience R seems much quicker at doing this than many well-known GIS ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2011/01/kml_thumb.png"><img class="aligncenter size-full wp-image-1790" title="Exporting KML from R" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/01/kml_thumb.png" alt="" width="621" height="250" /></a></p>
<p><a href="http://www.google.co.uk/intl/en_uk/earth/index.html" target="_blank">Google Earth </a>has become a popular way of disseminating spatial data. <a href="http://code.google.com/apis/kml/documentation/" target="_blank">KML</a> is the data format required to do this. It is possible to load almost any type of spatial data format into R and export it as a KML file. In my experience R seems much quicker at doing this than many well-known GIS platforms, such as <a href="http://www.esri.com/software/arcgis/index.html" target="_blank">ArcGIS</a>. The worksheet below explains how.</p>
<p><strong> Data and Package Requirements:</strong></p>
<p>London Cycle Hire Locations. <a href="http://dl.dropbox.com/u/10640416/London_cycle_hire_locs.csv">Download.</a></p>
<p>Install the following packages (if you haven’t already done so):</p>
<p><a href="http://cran.r-project.org/web/packages/maptools/index.html">maptools</a>, <a href="http://cran.r-project.org/web/packages/rgdal/index.html" target="_blank">rgdal</a> (Mac users may wish to <a href="http://spatialanalysis.co.uk/2010/11/02/installing-rgdal-on-mac-os-x/" target="_blank">see here first</a>).</p>
<h3><a href="http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/files/2011/01/exporting-to-kml.txt" target="_blank">Click here to view the tutorial code.</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2011/01/exporting-kml-from-r/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Installing rgdal on Mac OS X</title>
		<link>http://spatialanalysis.co.uk/2010/11/installing-rgdal-on-mac-os-x/</link>
		<comments>http://spatialanalysis.co.uk/2010/11/installing-rgdal-on-mac-os-x/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 17:43:06 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[R spatial]]></category>
		<category><![CDATA[rgdal]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=1523</guid>
		<description><![CDATA[******Roger Bivand has kindly just emailed me to say: &#8220;Your 2 November blog about rgdal on OSX is very misleading. The CRAN rgdal page: http://cran.r-project.org/web/packages/rgdal/index.html says all you need to know unless you need extra drivers, or already have PROJ.4 and GDAL installed. Just do: setRepositories(ind=1:2) install.packages(&#8220;rgdal&#8221;) installs rgdal with all its external dependencies satisfied. It is ...]]></description>
			<content:encoded><![CDATA[<p>******Roger Bivand has kindly just emailed me to say:</p>
<p>&#8220;Your 2 November blog about rgdal on OSX is very misleading. The CRAN rgdal page: <a href="http://cran.r-project.org/web/packages/rgdal/index.html" target="_blank">http://cran.r-project.org/web/<wbr>packages/rgdal/index.html</wbr></a> says all you need to know unless you need extra drivers, or already have PROJ.4 and GDAL installed. Just do:</p>
<p>setRepositories(ind=1:2)<br />
install.packages(&#8220;rgdal&#8221;)</p>
<p>installs rgdal with all its external dependencies satisfied. It is kindly provided by Prof. Brian Ripley, and is presently running up-to-date GDAL.&#8221;******</p>
<p>This may offer a straightforward solution. I would be interested to hear how people get on.</p>
<p>After running a spatial data analysis with R session today, it became apparent that there are one or two teething problems installing the important <a href="http://cran.r-project.org/web/packages/rgdal/index.html" target="_blank">rgdal </a>package on Mac OS X operating systems. The usual install.packages(&#8220;rgdal&#8221;) won&#8217;t work. My colleague <a href="http://www.casa.ucl.ac.uk/people/person.asp?ID=226" target="_blank">Jon Reades</a> did some digging around to find this solution. I have tested it and it seems to work fine.</p>
<p>[Note that you'll need to be comfortable with the Terminal. If you're not, then find someone who is.]</p>
<p>1. Download the GDAL OS X install from kyngchaos<br />
- <a href="http://www.kyngchaos.com/files/software/unixport/GDAL_Complete-1.7.dmg" rel="nofollow">http://www.kyngchaos.com/files/software/unixport/GDAL_Complete-1.7.dmg</a><br />
(Looks like the basic page [for updates after 1.7 if you're reading this ages from now] is <a href="http://www.kyngchaos.com/software/frameworks%29" rel="nofollow">http://www.kyngchaos.com/software/frameworks)</a><br />
- Install as per usual OS X install system<br />
- Fire up the Terminal, then pico (or vi[m]) the .bash_login file<br />
- Modify the PATH environment so that it reads:<br />
export PATH=”/Library/Frameworks/GDAL.framework/Programs:$PATH”<br />
[This is what enables the subsequent steps to find gdal-config]</p>
<p>2. Download and install proj4 from source<br />
- <a href="http://trac.osgeo.org/proj/wiki/WikiStart#Download" rel="nofollow">http://trac.osgeo.org/proj/wiki/WikiStart#Download</a><br />
- Download source code version proj-4.7.0.tar.gz<br />
- Fire up the Terminal<br />
&gt; cd ~/Downloads/<br />
&gt; tar -xzvf proj-4.7.0.tar.gz<br />
&gt; cd proj-4.7.0<br />
&gt; ./configure<br />
&gt; make &amp;&amp; make test<br />
&gt; sudo make install<br />
[ should install to /usr/local/lib by default]</p>
<p>3. Download and install rgdal from source<br />
- <a href="http://cran.r-project.org/src/contrib/rgdal_0.6-28.tar.gz" rel="nofollow">http://cran.r-project.org/src/contrib/rgdal_0.6-28.tar.gz</a><br />
- Fire up the Terminal<br />
&gt; cd ~/Downloads/<br />
&gt; sudo R CMD INSTALL –configure-args=’–with-proj-include=/usr/local/lib’ rgdal_0.6-28.tar.gz</p>
<p>After all of this mucking about I was able to say:</p>
<p>&gt; require(sp)<br />
&gt; require(rgdal)</p>
<p>And get a message indicating that GDAL was loaded successfully.</p>
<p>He also posted his solution on the <a href="http://www.compmath.com/blog/2010/07/installing-package-on-mac-os-x/#comment-332" target="_blank">Computational Mathematics Blog</a>. If there is a better way I would be interested in hearing about it for future classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2010/11/installing-rgdal-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Maps with ggplot2</title>
		<link>http://spatialanalysis.co.uk/2010/09/maps-with-ggplot2/</link>
		<comments>http://spatialanalysis.co.uk/2010/09/maps-with-ggplot2/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 08:41:40 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[R Spatial Tips]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[rspatialtips]]></category>
		<category><![CDATA[rstats]]></category>

		<guid isPermaLink="false">http://jamescheshire.co.uk.blogs.splintdev.geog.ucl.ac.uk/?p=1448</guid>
		<description><![CDATA[The ggplot2 package offers powerful tools to plot data in R. The plots are designed to comply with the “grammar of graphics” philosophy and can be produced to a publishable level relatively easily. For users wishing to create a good map without too much thought I would recommend this worksheet. For those without their own ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://spatialanalysis.co.uk/wp-content/uploads/2010/09/Screen-shot-2010-09-27-at-09.25.58.png"><img class="aligncenter size-full wp-image-1450" title="ggplot2 map" src="http://spatialanalysis.co.uk/wp-content/uploads/2010/09/Screen-shot-2010-09-27-at-09.25.58.png" alt="" width="496" height="359" /></a></p>
<p>The ggplot2 package offers powerful tools to plot data in R. The plots are designed to comply with the “<a href="http://books.google.co.uk/books?id=_kRX4LoFfGQC&amp;printsec=frontcover&amp;dq=grammar+of+graphics&amp;hl=en&amp;ei=E1igTIjMIMaXOOi22PgM&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1&amp;ved=0CDcQ6AEwAA#v=onepage&amp;q&amp;f=false" target="_blank">grammar of graphics</a>” philosophy and can be produced to a publishable level relatively easily. For users wishing to create a good map without too much thought I would recommend this worksheet. For those without their own shapefiles who rely on the “maps” package they may wish to consult <a href="http://had.co.nz/" target="_blank">Hadley Wickham</a>&#8216;s ggplot2 <a href="http://had.co.nz/ggplot2/book/">book</a>.</p>
<p><strong> Data Requirements:</strong></p>
<p>London Sport Participation Shapefile. <a href="http://spatialanalysis.co.uk/files/2010/09/London_Sport.zip">Download </a>(requires unzipping)</p>
<p>poly_coords function. <a href="http://dl.dropbox.com/u/10640416/poly_coords_function.R" target="_blank">Download</a></p>
<p>Install the following <strong>packages </strong>(if you haven’t already done so):</p>
<p><a href="http://cran.r-project.org/web/packages/maptools/index.html" target="_blank">maptools</a>, <a href="http://cran.r-project.org/web/packages/RColorBrewer/index.html" target="_blank">RColorBrewer</a>, <a href="http://cran.r-project.org/web/packages/ggplot2/index.html" target="_blank">ggplot2</a></p>
<h3><a href="http://spatialanalysis.co.uk/wp-content/uploads/2010/09/ggplot2_maps.txt" target="_blank"><strong>Click here to view the tutorial code</strong>.</a></h3>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://spatialanalysis.co.uk/2010/09/maps-with-ggplot2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

