In the last lecture I introduced a case study about roadside pollution.
As a recap
I also have some advanced visualisations to show you, demonstrating how I moved beyond GIS.
None of these are about energy, but the process and methods are directly transferable
Schools and limit values
Using 2015 data and a distance of 150 m or less to roads exceeding the EU limit value. Schools within 150 m of roads exceeding the limit value by type:
Rank |
Local Authority Name |
Number Of Pupils |
1 |
Hackney, London Borough of |
18323 |
2 |
Camden, London Borough of |
15955 |
3 |
Tower Hamlets, London Borough of |
14977 |
4 |
Lambeth, London Borough of |
14780 |
5 |
Kensington & Chelsea, Royal Borough of |
14274 |
6 |
Wandsworth, London Borough of |
13162 |
7 |
Southwark, London Borough of |
12517 |
8 |
Islington, London Borough of |
10705 |
9 |
Westminster, London Borough of |
10673 |
10 |
Newham, London Borough of |
9870 |
11 |
Hammersmith & Fulham, London Borough of |
9774 |
12 |
Haringey, London Borough of |
9516 |
13 |
Lewisham, London Borough of |
8000 |
14 |
Birmingham City Council |
7250 |
15 |
Hounslow, London Borough of |
6899 |
16 |
Enfield, London Borough of |
6515 |
17 |
Ealing, London Borough of |
6009 |
18 |
Barnet, London Borough of |
5907 |
19 |
Stockport Metropolitan Borough Council |
5660 |
20 |
Merton, London Borough of |
4312 |
Text
Excellent visual outcomes and a national campaign ...
# Load them into a pandas table
no2 = pandas.read_csv('../data/CSV/LAEI2016_2016_NO2.csv')
pm25 = pandas.read_csv('../data/CSV/LAEI2016_2016_PM25.csv')
edub = pandas.read_csv('../data/edubasealldata20190816.csv', encoding = "ISO-8859-1", low_memory = False)
bors = ['Barking and Dagenham', 'Barnet' ,'Bexley','Brent', 'Bromley','Camden','Croydon','Ealing',
'Enfield','Greenwich','Hackney', 'Hammersmith and Fulham','Haringey','Harrow','Havering','Hillingdon'
,'Hounslow','Islington', 'Kensington and Chelsea','Kingston upon Thames', 'Lambeth', 'Lewisham',
'Merton', 'Newham', 'Redbridge', 'Richmond upon Thames', 'Southwark', 'Sutton', 'Tower Hamlets',
'Waltham Forest','Wandsworth','Westminster']
len(edub.loc[edub["LA (name)"].isin(bors)])
len(edub.loc[(edub["LA (name)"].isin(bors) & (edub["PhaseOfEducation (name)"] == "Nursery"))])
len(edub.loc[(edub["LA (name)"].isin(bors) & (edub["TypeOfEstablishment (name)"] == "Local authority nursery school"))])
len(edub.loc[(edub["LA (name)"].isin(bors) & (edub["NurseryProvision (name)"] == "Has Nursery Classes"))])
# 2316
len(edub.loc[(edub["LA (name)"].isin(bors) & (edub["NurseryProvision (name)"] == "Has Nursery Classes") &
(edub["TypeOfEstablishment (name)"] == "Local authority nursery school"))])
# 81
nurseries =nurseries.append(edub.loc[(edub["LA (name)"].isin(bors) &
(edub["TypeOfEstablishment (name)"] == "Local authority nursery school"))])
nurseries = nurseries.drop_duplicates('URN')
nurseries = nurseries.loc[nurseries.Easting !=0]
nurseries.to_csv("../data/london_nurseries_edubase_2019.csv")
plt.figure(figsize=(30,30))
plt.scatter(no2.x.values, no2.y.values,c = no2.conc.values )
plt.scatter(nurseries.Easting.values, nurseries.Northing.values)
from scipy.spatial import KDTree
from shapely.geometry import Point
nursery_pts = nurseries[["Easting", "Northing"]].values
no2_tree = KDTree(no2[['x','y']].values)
nearest_no2 = no2_trees.query(nursery_pts)
pm25_tree = KDTree(pm25[['x','y']].values)
nearest_pm25 = pm25_tree.query(nursery_pts)
no2_x = []
no2_y = []
no2_concs = []
for i in nearest_no2[1]:
no2_x.append(no2.loc[i]["x"])
no2_y.append(no2.loc[i]["y"])
no2_concs.append(no2.loc[i]["conc"])
nurseries["no2_x"] = no2_x
nurseries["no2_y"] = no2_y
nurseries["no2_µg/m3"] = no2_concs
pm_x = []
pm_y = []
pm_concs =[]
for i in nearest_pm25[1]:
pm_x.append(pm25.loc[i]["x"])
pm_y.append(pm25.loc[i]["y"])
pm_concs.append(pm25.loc[i]["conc"])
nurseries["pm_x"] = pm_x
nurseries["pm_y"] = pm_y
nurseries["pm25_µg/m3"] = pm_concs
max(nurseries["pm_x"] - nurseries["Easting"])
max(nurseries["pm_y"] - nurseries["Northing"])
max(nurseries["no2_y"] - nurseries["Northing"])
max(nurseries["no2_x"] - nurseries["Easting"])
nurseries.to_csv("../data/london_nurseries_edubase_2019_with_concs.csv")
Web GIS and advanced vis examples
To convert data to geojson
lats = []
lons = []
for i in nurs.index:
r = requests.get("https://www.bgs.ac.uk/data/webservices/CoordConvert_LL_BNG.cfc?method=BNGtoLatLng&easting="
+str(nurs.loc[i]["Easting"])+"&northing="+str(nurs.loc[i]["Northing"]), verify=False)
rr = json.loads(r.text)
lats.append(rr["LATITUDE"])
lons.append(rr["LONGITUDE"])
nurs["x"] = lons
nurs["y"] = lats
def data2geojson(df):
features = []
insert_features = lambda X: features.append(
geojson.Feature(geometry=geojson.Point((X["X"],
X["Y"],
0)),
properties=dict(URN=X["URN"],
NO2_conc=X['no2_µg/m3'],
PM25_conc=X['pm25_µg/m3'],
EstablishmentName= X['EstablishmentName'],
NumberOfPupils=X['NumberOfPupils'],
Address=X['Street']
)))
df.apply(insert_features, axis=1)
with open('nursery.geojson', 'w', encoding='utf8') as fp:
geojson.dump(geojson.FeatureCollection(features), fp, sort_keys=True, ensure_ascii=False)
data2geojson(nurs)