https://www.gov.uk/government/collections/journey-time-statistics
https://www.gov.uk/government/statistical-data-sets/journey-times-to-key-services-by-lower-super-output-area-jts05 https://www.gov.uk/government/statistical-data-sets/journey-times-to-key-services-by-local-authority-jts04
from __future__ import division
%matplotlib inline
import pandas as pd
gp='https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/485260/jts0505.xls'
xl=pd.ExcelFile(gp)
xl.sheet_names
[u'Metadata', u'JTS0505']
tname='JTS0505'
dbd=xl.parse(tname,skiprows=6)
dbd[:3]
LSOA_code | Region | LA_Code | LA_Name | GP_pop | GPPTt | GPPT15n | GPPT30n | GPPT45n | GPPT60n | ... | GPCyc60pct | GPCart | GPCar15n | GPCar30n | GPCar45n | GPCar60n | GPCar15pct | GPCar30pct | GPCar45pct | GPCar60pct | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | E01000001 | London | E09000001 | City of London | 809 | 3.348711 | 2.117429 | 10 | 10 | 10 | ... | 100 | 7.768724 | 10 | 10 | 10 | 10 | 100 | 100 | 100 | 100 |
1 | E01000002 | London | E09000001 | City of London | 947 | 8.154639 | 1.645195 | 10 | 10 | 10 | ... | 100 | 8.527993 | 10 | 10 | 10 | 10 | 100 | 100 | 100 | 100 |
2 | E01000003 | London | E09000001 | City of London | 846 | 6.424466 | 2.365248 | 10 | 10 | 10 | ... | 100 | 8.935269 | 10 | 10 | 10 | 10 | 100 | 100 | 100 | 100 |
3 rows × 32 columns
foodstore='https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/485262/jts0507.xls'
xl=pd.ExcelFile(foodstore)
xl.sheet_names
[u'Metadata', u'JTS0507']
tname='JTS0507'
dbd2=xl.parse(tname,skiprows=6)
iwfood=dbd2[dbd2['LA_Code']=='E06000046']
iwfood[:3]
LSOA_code | Region | LA_Code | LA_Name | Town_pop | TownPTt | TownPT15n | TownPT30n | TownPT45n | TownPT60n | ... | TownCyc60pct | TownCart | TownCar15n | TownCar30n | TownCar45n | TownCar60n | TownCar15pct | TownCar30pct | TownCar45pct | TownCar60pct | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
16777 | E01017282 | South East | E06000046 | Isle of Wight | 600 | 7.259422 | 2.000000 | 10.000000 | 10 | 10 | ... | 100 | 6.593640 | 10.000000 | 10.000000 | 10.000000 | 10.000000 | 100 | 100 | 100 | 100 |
16778 | E01017283 | South East | E06000046 | Isle of Wight | 677 | 11.211987 | 2.035451 | 10.000000 | 10 | 10 | ... | 100 | 7.705013 | 9.805022 | 9.805022 | 9.805022 | 9.805022 | 100 | 100 | 100 | 100 |
16779 | E01017284 | South East | E06000046 | Isle of Wight | 797 | 6.786982 | 1.146801 | 4.833124 | 10 | 10 | ... | 100 | 6.948125 | 5.594730 | 10.000000 | 10.000000 | 10.000000 | 100 | 100 | 100 | 100 |
3 rows × 32 columns
iw=dbd[dbd['LA_Code']=='E06000046']
import fiona
code='E06000046'
geojson='https://github.com/martinjc/UK-GeoJSON/raw/master/json/statistical/eng/lsoa_by_lad/{}.json'.format(code)
!wget {geojson}
#fi=fiona.open('../IWgeodata/wards_by_lad/E06000046.json')
geojson_local='{}.json'.format(code)
fi=fiona.open(geojson_local)
centre_lat,centre_lon=((fi.bounds[0]+fi.bounds[2])/2,(fi.bounds[1]+fi.bounds[3])/2)
--2015-12-18 16:56:01-- https://github.com/martinjc/UK-GeoJSON/raw/master/json/statistical/eng/lsoa_by_lad/E06000046.json Resolving github.com... 192.30.252.130 Connecting to github.com|192.30.252.130|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/statistical/eng/lsoa_by_lad/E06000046.json [following] --2015-12-18 16:56:01-- https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/statistical/eng/lsoa_by_lad/E06000046.json Resolving raw.githubusercontent.com... 23.235.43.133 Connecting to raw.githubusercontent.com|23.235.43.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 288412 (282K) [text/plain] Saving to: 'E06000046.json.1' E06000046.json.1 100%[=====================>] 281.65K --.-KB/s in 0.09s 2015-12-18 16:56:02 (3.22 MB/s) - 'E06000046.json.1' saved [288412/288412]
import folium
import folium
m = folium.Map([centre_lon,centre_lat], zoom_start=11)
m.choropleth(
geo_path=geojson_local,
data=iw,
columns=['LSOA_code', 'GPPTt'],
key_on='feature.properties.LSOA11CD',
fill_color='PuBuGn', fill_opacity=1.0
)
'''
m.choropleth(
geo_path=geojson_local,
data=iwfood,
columns=['LSOA_code', 'FoodPTt'],
key_on='feature.properties.LSOA11CD',
fill_color='PuBuGn', fill_opacity=1.0
)
'''
m
/Users/ajh59/anaconda/lib/python2.7/site-packages/ipykernel/__main__.py:9: FutureWarning: 'threshold_scale' default behavior has changed. Now you get a linear scale between the 'min' and the 'max' of your data. To get former behavior, use folium.utilities.split_six.
import os
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
delay=5
fn='testmap.html'
tmpurl='file://{path}/{mapfile}'.format(path=os.getcwd(),mapfile=fn)
m.save(fn)
browser = webdriver.Firefox()
browser.get(tmpurl)
#Give the map tiles some time to load
time.sleep(delay)
browser.save_screenshot('map.png')
browser.quit()