Plotting PM2.5 on Bonfire Night using the UO api v1.1

import modules

In [12]:
import requests
from IPython.display import GeoJSON
import pandas as pd
import io

Retrieve Sensors

In [12]:
sensor_params = dict(
    sensor_type='PM2.5',
subset_layer='Post code Districts',
subset_shapes='NE1',
)

r = requests.get('http://uoweb3.ncl.ac.uk/api/v1.1/sensors/csv/',sensor_params)

sensor_info = pd.read_csv(io.StringIO(r.text) )
sensor_info
Out[12]:
Sensor Name Location (WKT) Ground Height Above Sea Level Sensor Height Above Ground Broker Name Third Party Sensor Centroid Longitude Sensor Centroid Latitude
0 PER_AIRMON_MESH1765150 POINT (-1.61014 54.97461) 42.740002 2.0 Air Monitors False -1.610140 54.974610
1 PER_AIRMON_MESH1957150 POINT (-1.613215 54.981701) 55.549999 2.0 Air Monitors False -1.613215 54.981701
2 PER_AIRMON_MESH1756150 POINT (-1.617166 54.974211) 47.369999 2.0 Air Monitors False -1.617166 54.974211
3 PER_AIRMON_MESH1757150 POINT (-1.61731 54.97226) 45.369999 2.0 Air Monitors False -1.617310 54.972260
4 PER_AIRMON_MESH1763150 POINT (-1.606514 54.973793) 35.040001 2.0 Air Monitors False -1.606514 54.973793
5 PER_AIRMON_MESH1764150 POINT (-1.6135 54.97768) 47.599998 2.0 Air Monitors False -1.613500 54.977680
6 PER_AIRMON_MESH1758150 POINT (-1.61273 54.97575) 47.060001 2.0 Air Monitors False -1.612730 54.975750
7 PER_AIRMON_MESH1759150 POINT (-1.613355 54.977854) 47.779999 2.0 Air Monitors False -1.613355 54.977854
8 PER_AIRMON_MESH1760150 POINT (-1.61069 54.97223) 37.470001 2.0 Air Monitors False -1.610690 54.972230
9 PER_AIRMON_MESH1761150 POINT (-1.61169 54.97431) 43.669998 2.0 Air Monitors False -1.611690 54.974310
10 PER_AIRMON_MESH1762150 POINT (-1.611006 54.973198) 41.500000 2.0 Air Monitors False -1.611006 54.973198
11 PER_AIRMON_MESH1908150 POINT (-1.614957 54.971422) 41.869999 2.0 Air Monitors False -1.614957 54.971422
12 PER_AIRMON_MESH1915150 POINT (-1.718833 54.995352) 107.669998 2.0 Air Monitors False -1.718833 54.995352
13 PER_AIRMON_MESH1918150 POINT (-1.614074 54.972656) 42.410000 2.0 Air Monitors False -1.614074 54.972656
14 PER_AIRMON_MESH1906150 POINT (-1.609379 54.973601) 38.169998 2.0 Air Monitors False -1.609379 54.973601

plot location of sensors

In [13]:
import smopy
import matplotlib.patheffects as pe

bbox = (
min(sensor_info['Sensor Centroid Latitude']),
    min(sensor_info['Sensor Centroid Longitude']),
    max(sensor_info['Sensor Centroid Latitude']),
    max(sensor_info['Sensor Centroid Longitude']),
)

map = smopy.Map(bbox, z=17)
ax = map.show_mpl(figsize=(15, 15))
for i,row in sensor_info.iterrows():
    x, y = map.to_pixels(row['Sensor Centroid Latitude'], row['Sensor Centroid Longitude'])
    ax.plot(x, y, 'ob', ms=20, mew=2);
    
Lowered zoom level to keep map size reasonable. (z = 13)