Skip to content

Instantly share code, notes, and snippets.

@chris-creditdesign
Last active August 29, 2015 14:22
Show Gist options
  • Save chris-creditdesign/ae85e54f1d15a691feef to your computer and use it in GitHub Desktop.
Save chris-creditdesign/ae85e54f1d15a691feef to your computer and use it in GitHub Desktop.
.DS_Store
build/
node_modules

#Lets make a dancing bubble map

I'm going to draw on Mike Bostocks excellent Let's make a map and Let's make a bubble map tutorials to make a bubble map of my own.

The case where the bubbles overlap each other.

I've downloaded Population data for UK cities from the centre for cities website a charitable research organisation based in the UK.

The resulting csv file is slightly irregular in that it contains an extra 10 lines containing source and credit information. You can remove these lines by hand or use this rather conveluted command on in the Mac terminal:

tail -r population_2013.csv | sed '1,10d' | tail -r > temp.csv && mv temp.csv population_2013.csv

N.B this is rather convoluted because we need to reverse the order of the file with tail -r before removing the top ten lines and then reversing it once again. I'm sure there's a better way to do this!

The resulting file should look like this:

City,"Population 2013"
Aberdeen,227100
Aldershot,181900
Barnsley,235800
Belfast,675600
Birkenhead,320300
Birmingham,2453700
Blackburn,147400

http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip

NATURAL_EARTH_CDN = http://naciscdn.org/naturalearth
TOPOJSON = node_modules/.bin/topojson
# http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_map_subunits.zip
build/ne_10m_populated_places.shp: build/ne_10m_populated_places.zip
unzip -d $(dir $@) $<
touch $@
build/ne_10m_populated_places.zip:
mkdir -p $(dir $@)
curl "$(NATURAL_EARTH_CDN)/10m/cultural/$(notdir $@)" -o [email protected]
mv [email protected] $@
node_modules/.bin/topojson:
npm install
places.json: build/ne_10m_populated_places.shp
ogr2ogr \
-f GeoJSON \
-where "ISO_A2 = 'GB'" \
$@ \
$<
{
"name":"anonymous",
"private":true,
"version":"0.0.1",
"dependencies": {
"topojson":"1"
}
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
City Population 2013
Aberdeen 227100
Aldershot 181900
Barnsley 235800
Belfast 675600
Birkenhead 320300
Birmingham 2453700
Blackburn 147400
Blackpool 326100
Bolton 280100
Bournemouth 386100
Bradford 526400
Brighton 340600
Bristol 706600
Burnley 177000
Cambridge 126500
Cardiff 351700
Chatham 271100
Coventry 329800
Crawley 250000
Derby 251400
Doncaster 303600
Dundee 148200
Edinburgh 487500
Glasgow 1057600
Gloucester 124600
Grimsby 159800
Hastings 90800
Huddersfield 428300
Hull 257600
Ipswich 134700
Leeds 761500
Leicester 485000
Liverpool 793100
London 9750500
Luton 208000
Manchester 1903100
Mansfield 226800
Middlesbrough 467100
Milton Keynes 255700
Newcastle 837500
Newport 146600
Northampton 216700
Norwich 261400
Nottingham 650100
Oxford 154800
Peterborough 188400
Plymouth 259200
Portsmouth 526100
Preston 359800
Reading 433700
Rochdale 212100
Sheffield 818800
Southampton 369900
Southend 348300
Stoke 375500
Sunderland 276100
Swansea 240300
Swindon 214000
Telford 168500
Wakefield 329700
Warrington 205100
Wigan 319700
Worthing 106100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment