-
Notifications
You must be signed in to change notification settings - Fork 1
/
air.py
32 lines (28 loc) · 934 Bytes
/
air.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import requests
def getAirInfoGeo(lat, lng):
url = "http://localhost:5000/api/ambeedata/air/geospatial?lat={}&lng={}".format(lat, lng)
results = requests.get(url)
data = results.json()
NO2 = data["stations"][0]["NO2"]
PM10 = data["stations"][0]["PM10"]
PM25 = data["stations"][0]["PM25"]
CO = data["stations"][0]["CO"]
SO2 = data["stations"][0]["SO2"]
OZONE = data["stations"][0]["OZONE"]
AQI = data["stations"][0]["AQI"]
pollutant = data["stations"][0]["aqiInfo"]["pollutant"]
concentration = data["stations"][0]["aqiInfo"]["concentration"]
category = data["stations"][0]["aqiInfo"]["category"]
info = {
"NO2": NO2,
"PM10": PM10,
"PM25": PM25,
"CO": CO,
"SO2": SO2,
"OZONE": OZONE,
"AQI": AQI,
"pollutant": pollutant,
"concentration": concentration,
"category": category
}
return info