Tuesday, 26 July 2016

Urban road network data for 80 world cities

A recent study published in Nature's Scientific Data caught my eye recently. In the paper, published online on 21 June 2016, the authors describe a method for taking OpenStreetMap (OSM) data and producing usable, toplogically accurate network data from it. It covers 80 of the biggest cities across the world, from Tokyo to Medellin. What caught my eye in particular is that they shared all the data on Figshare, and you can download it in chunks or the whole lot at once (2.15GB). I had a little play with it and made some night time/from space views of the network data, just for fun. Guess the cities below (helpful clues included)... and then tell me which is the odd one out.

Clue: it's not Bognor Regis 

Clue: I have been there (that's not very helpful, sorry) 

Clue: lots of people live here

Clue: rhymes with Few Dork

Clue: lots and lots and lots of people live here

Back on topic now - here's what the study looks like if you haven't already clicked - the authors also provide loads of useful resources in the paper. They also describe how they were able to develop a topologically accurate street network using their GIS-based protocol.

Take a look at the study - it's great

The 80 cities featured



Citation: Karduni,A., Kermanshah, A., and Derrible, S., 2016, "A protocol to convert spatial polyline data to network formats and applications to world urban road networks", Scientific Data, 3:160046, Available at http://www.nature.com/articles/sdata201646


Friday, 15 July 2016

From CartoDB to CARTO - the future of interactive mapping?

I've been using CartoDB (now CARTO) for a few years for interactive mapping - and have always loved what it can do - from basic mapping to much more complex analysis. Now, with the re-brand as CARTO and the advanced analytical tools available through the new Builder interface it's on a new level. So, credit where credit's due - I thought I'd do a short piece on this now to give my take on the new interface. But first, here's a little gif of me playing around with some commute data - which you can also download yourself if you want to. The dataset was used as part of a project I've been working on with Garrett Nelson - but hopefully more on that in future.

I'm just playing around turning things on and off here

If you've used the old CartoDB interface, the new Builder one might be a bit confusing at first - though you may not actually be able to get access to it yet. But once you have played around with it for a few minutes it soon becomes pretty intuitive. I uploaded a sub-set of commute flow lines for Minnesota and Wisconsin and then decided to add widgets so that I could filter the data using line distance, FIPS codes and commute volumes - as you should be able to see in the larger image below.

Click to enlarge - change the data view by using tools on right

This is very much just a little data sample, but if you want to play around with the interactive CARTO map you can see it here. It's not very pretty and the origins and destinations don't have place names right now - only FIPS codes - but the principle is the same. The Widget interface takes a little bit of getting used to as well, but is really easy to use once you've figured out what's what. See below for a screenshot.

You can add widgets for different data types

Any negatives to report? For me, not now. I'm just enjoying the enhanced analytical tools at hand. But if I was being greedy... I'm not massively keen on the default legends, there doesn't appear to be an 'addition' blend mode and the snap alignment of shapes in the old map editor has me a little flummoxed, but these are minor grumbles.

I'm not getting paid to promote this and I don't know anyone at CARTO - honest - I just think they have produced something that works brilliantly, is simple yet powerful and allows us to manipulate, analyse and share our data in new ways. There are other tools out there but the new Builder, for me, takes things to the next level for a mass audience. To answer the question in the title of the blog: is CARTO the future of interactive mapping, then? Not the future, but probably a very big part of it.


Notes: really, they didn't pay me. Data used are from the American Community Survey. I wrote a working paper on it already. I also blogged about it on my old blog. Finally, if you're one of the few people in the world not to have seen it, Mark Evans created this beautiful site with the same data.




Saturday, 25 June 2016

What can explain Brexit?

There have been enough maps, charts and infographics on Brexit already, so I'll just post three scatterplots here. I was trying to figure out what was going on, so I explored a few key variables that I thought might explain why people voted the way they did. I chose deprivation, lack of qualifications and higher qualifications, using 2011 Census data. I only focused on England here. Some of it has been done already by John Burn-Murdoch at the FT, though in a different (much nicer) way.

First, deprivation is - overall - not strongly correlated with percent voting leave at the local authority level (R-squared is 0.0369). I used 2015 Indices of Deprivation at the local authority level in the scatterplot below, where I've also labelled some areas and coloured the points by region. 

Click to enlarge

Next, I decided to look at whether the percent of people with no qualifications correlated closely with the percent voting for leave in each local authority in England. This was much more successful, with an R-Squared of 0.6197. 

A pretty convincing pattern here

Finally, I decided to see whether higher levels of education - rather than lack of education - was more strongly associated with the propensity to vote leave, and it is. In the scatterplot below I compare the percent with Level 4 qualifications or above with the percent voting to leave the EU. This produces an R-squared value of 0.8053, which is really pretty high.

The outlier to the top left is the City of London

This may not be particularly surprising, given what is known about the link between voting patterns and education but I think it's particularly interesting because of i) the historic significance of this referendum and ii) the people likely to be hardest hit by any post-Brexit economic downturn.


Data sources: Census 2011 table KS501EW via NOMIS and EU Referendum data is from the Electoral Commission. I have shared the spreadsheet (and the Level 4 vs. % leave) here in case anyone wants to look more closely or make an interactive version.

Sunday, 12 June 2016

International collaboration, without leaving the house (or, why social media can be a good thing)

The idea behind today's post is in some ways blindingly obvious, but also often overlooked. Basically, it's that sharing ideas online can lead to all sorts of interesting, unexpected international collaborations of various types. I'm talking here specifically about research and academic-related collaboration, but it could apply to just about anything. I thought I'd share a short maps/viz story about this, just to demonstrate that 'internationalisation' (a common feature of University policy) doesn't mean having to cram yourself into a plane for 10 hours to some far flung paradise. But of course I should start with a map.



It's a bit of an eyesore in some ways, but that's not the point. Here's the story, and the point...

I'd been doing some work on mapping travel to work flows, since the data were released for England and Wales in the summer of 2014. Some time after that, another University of Sheffield department were contacted by a scholar from Turkey (Ebru Sener) asking about the possibility of visiting on a short Erasmus-funded trip. The other department didn't follow up so I looked into it, Skyped with Ebru and quickly discovered we had a lot of common interests and a good amount of overlap in our skills - but also, crucially, areas where we could learn from each other.

This led to a research visit in 2015, during which time we wrote a paper on housing market search (now published in Cities). Ebru also taught a class for me that week, which was great. We then kept in touch via e-mail and social media and it was Ebru that suggested I make the commuter dots go back to where they came from, which I thought was a nice touch and I then wrote this stuff up into a short piece for the Huffington Post after they got in touch (I have a paper on that coming out in future as well).



That summer, I experimented further on this area of research by looking at US commuting flows at the small area level. I published a short working paper on it, as well as a couple of blog pieces, plus the data I created from it. This then led to a brilliant US scholar (Garrett Nelson) taking a sub-set of the data and using a community partitioning algorithm to derive communities for one state (Massachusetts - see below). He blogged this, told me about it on Twitter and then I had a new idea so contact him again to see if he wanted to collaborate on a project to do this for the whole United States. Once again, we Skyped, made a plan and then got to work (side note: we used cloud computing because the data had outgrown the desktop environment).



Now we've almost finished our paper and - we hope - this will lead to further collaboration on the topic.

Following this, the brilliant Mark Evans (from Michigan) got in touch to say he was planning something which built on some of the ideas I'd had in order to build an interactive US version of the animated dot map you see above. He built it, shared with me and then it went kind of viral - with many news sites and local and regional outlets picking it up (Daily Mail, CityLab, WIRED, Boston.com etc.). I don't claim that I could have done this but it's nice to know I was, in part, a source of inspiration. Mark has also shared his method, which is great for further collaboration and other users. In the gif below you can see that Mark has coloured the dots based on where people come from, which is a nice innovation.



And the point? International collaboration and internationalisation seem to be talked about a lot in terms of travel, short and medium-term study visits and can be a logistical nightmare. Often, it's necessary though. The kind of thing I've discussed above can be an additional means of 'internationalisation' that is both cost effective and time efficient. I haven't seen that much about the possibilities for formal international collaboration through social media. This might be because I don't pay attention. 


Having said that you can do international collaboration without leaving the house, I am of course off to the US this week for a conference... 

Friday, 27 May 2016

City Footprints

Earlier in the week I posted a map of London's 'economic hinterland' on Twitter because I've been working with commuting data and wanted to see what the economic footprint of London looks like. But, some people have been telling me that other cities exist - which is a fair point. Since I have the data and I'm just revising a paper on the topic I thought I'd look at a few others, but this time using lower level data - MSOAs instead of districts for the origins. The maps below show the proportion of people from an MSOA who commute to a given area. Only MSOAs with 1% or more going to a particular place are shown and the darker the colour the higher the percentage. These aren't exactly the same as travel to work areas but they do give a reasonable approximation of each city's economic footprint. As you can see, I did quite a few maps - click to enlarge, as ever.

Birmingham has quite a pleasing concentric pattern

Bradford has quite a wide footprint

Bristol - quite a neat footprint

Cambridge is a little wider than I expected

Camden - one of a few London Boroughs I looked at

Cardiff - clearly the major focus in South Wales

Cheshire West - I wanted to see how far into Wales it goes

Derby seems relatively tightly packed

Leeds - the second largest local authority by population

Leicester - another quite tight East Midlands labour market area

Liverpool - extends into Wales and south to Cheshire, as you'd expect 
Greater London - the light areas are only 1% of commuters, but still!

Greater London - same as above, but with some city labels

Manchester - only the 'underbounded' district here, but still dominant

Middlesbrough - an important northern labour market area

Milton Keynes - I think it has quite a wide footprint

Newcastle - clearly dominant in the North East

Norwich - a good example of a large regional labour market area

Nottingham is relatively symmetrical in labour market terms

Oxford - a relatively large footprint here

Plymouth is a major South West economic zone

Reading - I had expected this to be a little bigger

Sheffield is another major northern labour market area

Southampton - somewhat overlaps with London's fringe

Southwark - I wanted to see how this London Borough looked

Swansea - quite a wide footprint here

Tower Hamlets - interesting to see the dominance of eastern origins

Warrington - a strategic hub in the North West

City and Westminster - the ONS group these two together

York - quite a wide Yorkshire footprint


Should I patch all these together in one big animated gif? Of course I should.

Why isn't my city included? Good question. Sincere apologies.

Birmingham doesn't get enough love, and is so often overlooked, so I did a zoomed in version of MSOA flows into Birmingham, with a few place labels.

Click here to see the full size version


Notes: the maps give the impression that they are unclassified choropleths, but that is just for effect and because this is a quick map batch. The colour classification is the same in each (see below) and no areas with less than 1% commuting to a given place are shown. I used the UK Data Service Flow Data website to extract the data and QGIS 2.14 for the maps. Bear in mind that they are a bit rough and ready and only really for comparison. Also, each 'city' here refers to the local authority area, not the wider city-region. But I think it's interesting to compare places. You just need to bear in mind the spatial scale and relative size of the destination places. Birmingham and Leeds ought to have much larger footprints that (e.g.) Nottingham and Sheffield because they contain more jobs. Where are Scotland and Northern Ireland? These datasets come separately and are not part of the English and Welsh MSOA geography so are not mapped here.

I used the same classification scheme for all maps