Thursday 15 August 2013

Uploading UK boundary maps to Google Fusion Tables

Here goes my first attempt at blogging! I thought I'd jot down a few notes on importing UK maps to Google Fusion Tables. There's loads of information online on creating maps (for example here), so I won't cover the basics of Fusion Tables.

A good place to start looking for boundaries is this blog post from Simon Rogers, which has several ready-made maps. If you don't find what you need there, try ONS's Open Geography Portal. The 'Download Boundaries' section is one option, but I find it's handier to use the 'Browse' section, then Digital Boundaries. Within this section, choose a geography type from the left panel, and select Details in the right panel. (Generalised files are smaller but less detailed than Full files. Clipped files are clipped to the coastline.)

Finally, scroll to the zip download, which is among the Transfer Options links.

You can then upload the shapefile to Fusion Tables using Shape Escape. As an alternative, I've found the rgdal package in R to be useful. This is an example script to create a KML file for uploading to Fusion Tables:

library(rgdal)
shapeFileName <- 'LAD_DEC_2010_GB_BGC.shp'
layerName <- ogrListLayers(shapeFileName)
ogrInfo(dsn,layerName)
shp <- readOGR(dsn=shapeFileName, layer=layerName)
shpWGS84 <- spTransform(shp,CRS("+proj=longlat +datum=WGS84"))
writeOGR(shpWGS84, "LA.kml", layer="LA",driver="KML")


You can also join data to the geographical boundaries in R, using the shp@data data frame. I don't have much experience of doing this, but I'd recommend trying the  join function from the plyr package.

For map colours, I'd recommend http://colorbrewer2.org/.

This is my first attempt at using D3 and Fusion Tables together for a map. I might cover some more details of this in another blog post, or feel free to ask!

No comments:

Post a Comment