#https://www.gov.uk/government/statistics/sub-national-electricity-and-gas-consumption-at-lsoa-msoa-and-igz-level-in-2015
import pandas as pd
gasurl='https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/585723/LSOA_domestic_gas_2015.xlsx'
elecurl='https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/585872/LSOA_domestic_electricity_2015.xlsx'
gas=pd.read_excel('data/LSOA_domestic_gas_2015.xlsx',sheetname=1,skiprows=1)
gas.head()
Local Authority Name | Local Authority Code | MSOA Name | Middle Layer Super Output Area (MSOA) Code | LSOA Name | Lower Layer Super Output Area (LSOA) Code | Consumption (kWh) | Number of meters | Mean consumption (kWh per meter) | Median consumption (kWh per meter) | |
---|---|---|---|---|---|---|---|---|---|---|
0 | City of London | E09000001 | City of London 001 | E02000001 | City of London 001A | E01000001 | 647907.34 | 58 | 11171 | 4046 |
1 | City of London | E09000001 | City of London 001 | E02000001 | City of London 001B | E01000002 | 292191.84 | 15 | 19479 | 7669 |
2 | City of London | E09000001 | City of London 001 | E02000001 | City of London 001C | E01000003 | 4483592.81 | 567 | 7908 | 6804 |
3 | City of London | E09000001 | City of London 001 | E02000001 | City of London 001E | E01000005 | 2867670.67 | 459 | 6248 | 3697 |
4 | Barking and Dagenham | E09000002 | Barking and Dagenham 016 | E02000017 | Barking and Dagenham 016A | E01000006 | 6003821.96 | 406 | 14788 | 14053 |
elec=pd.read_excel('data/LSOA_domestic_electricity_2015.xlsx',sheetname=1,skiprows=1)
elec.head()
Local Authority Name | Local Authority Code | Middle Layer Super Output Area (MSOA) Name | Middle Layer Super Output Area (MSOA) Code | Lower Layer Super Output Area (LSOA) Name | Lower Layer Super Output Area (LSOA) Code | Total domestic electricity consumption (kWh) | Total number of domestic electricity meters | Mean domestic electricity consumption (kWh per meter) | Median domestic electricity consumption (kWh per meter) | |
---|---|---|---|---|---|---|---|---|---|---|
0 | Hartlepool | E06000001 | Hartlepool 001 | E02002483 | Hartlepool 001A | E01011954 | 2968986.80 | 966 | 3073 | 2611 |
1 | Hartlepool | E06000001 | Hartlepool 001 | E02002483 | Hartlepool 001B | E01011969 | 2036143.40 | 639 | 3186 | 2856 |
2 | Hartlepool | E06000001 | Hartlepool 001 | E02002483 | Hartlepool 001C | E01011970 | 1621503.90 | 453 | 3579 | 3231 |
3 | Hartlepool | E06000001 | Hartlepool 001 | E02002483 | Hartlepool 001D | E01011971 | 2111305.50 | 530 | 3984 | 3460 |
4 | Hartlepool | E06000001 | Hartlepool 001 | E02002483 | Hartlepool 001F | E01033465 | 2906157.53 | 827 | 3514 | 3134 |
iwLA='E06000046'
def geoJlocal(code):
return '{}.json'.format(code)
geoJlocal(iwLA)
'E06000046.json'
import folium
#color brewer palettes: ‘BuGn’, ‘BuPu’, ‘GnBu’, ‘OrRd’, ‘PuBu’, ‘PuBuGn’, ‘PuRd’, ‘RdPu’, ‘YlGn’, ‘YlGnBu’, ‘YlOrBr’, and ‘YlOrRd’.
import fiona
geojson_local='travel-times/E06000046.json'
fi=fiona.open(geojson_local)
centre_lat,centre_lon=((fi.bounds[0]+fi.bounds[2])/2,(fi.bounds[1]+fi.bounds[3])/2)
elecmap = folium.Map([centre_lon,centre_lat], zoom_start=11)
elecmap.choropleth(
geo_path=geojson_local,
data=elec[elec['Local Authority Code']=='E06000046'],
columns=['Lower Layer Super Output Area (LSOA) Code', 'Total domestic electricity consumption (kWh)'],
key_on='feature.properties.LSOA11CD',
fill_color='PuBuGn', fill_opacity=1.0
)
gasmap = folium.Map([centre_lon,centre_lat], zoom_start=11)
gasmap.choropleth(
geo_path=geojson_local,
data=gas[gas['Local Authority Code']=='E06000046'],
columns=['Lower Layer Super Output Area (LSOA) Code', 'Consumption (kWh)'],
key_on='feature.properties.LSOA11CD',
fill_color='RdPu', fill_opacity=1.0
)
elecmap
gasmap