Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created September 26, 2017 16:15
Show Gist options
  • Save sergiolucero/d15071bc3c4b841d516a95ed64c3d752 to your computer and use it in GitHub Desktop.
Save sergiolucero/d15071bc3c4b841d516a95ed64c3d752 to your computer and use it in GitHub Desktop.
openAQ air quality
import openaq
parameters = ['co', 'no2', 'o3', 'pm10', 'pm25', 'so2']
api = openaq.OpenAQ()
country_list = api.countries(df=True)
print('MONITORING %d locations worldwide' %(country_list.locations.sum()))
for cid, cdata in country_list.iterrows():
ctry = cdata.name
print('Country %s [code %s] has %d locations' %(ctry, cdata.code, cdata.locations))
for par in parameters:
locations = api.locations(country=cdata.code, parameter=par, df=True)
for lid, location in locations.iterrows():
locdata = api.latest(location=location.location, country=cdata.code, df=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment