import requests
from folium import Map, TileLayer
Air Quality and COVID-19
Run this notebook
You can launch this notebook using mybinder, by clicking the button below.
Approach
- Identify available dates and temporal frequency of observations for a given collection - NO₂
- Pass the STAC item into raster API
/stac/tilejson.json
endpoint - We’ll visualize two tiles (side-by-side) allowing for comparison of each of the time points using
folium.plugins.DualMap
About the Data
This dataset is of monthly nitrogen dioxide (NO₂) levels values across the globe. Darker colors indicate higher NO₂ levels and more activity. Lighter colors indicate lower levels of NO₂ and less activity. Missing pixels indicate areas of no data most likely associated with cloud cover or snow.
The Case Study - Air Quality and COVID-19
In this notebook, we’ll walk through the development of side-by-side comparisons of NO₂ levels before and after government lockdowns as demonstrated Seeing Rebounds in NO₂
in this VEDA Discovery story: Air Quality and COVID-19 available on the VEDA Dashboard.
Querying the STAC API
# Provide STAC and RASTER API endpoints
= "https://openveda.cloud/api/stac"
STAC_API_URL = "https://openveda.cloud/api/raster"
RASTER_API_URL
# Declare collection of interest - Nitrogen Oxide
= "no2-monthly" collection_name
#Fetch STAC collection
= requests.get(f"{STAC_API_URL}/collections/{collection_name}").json()
collection collection
{'id': 'no2-monthly',
'type': 'Collection',
'links': [{'rel': 'items',
'type': 'application/geo+json',
'href': 'https://openveda.cloud/api/stac/collections/no2-monthly/items'},
{'rel': 'parent',
'type': 'application/json',
'href': 'https://openveda.cloud/api/stac/'},
{'rel': 'root',
'type': 'application/json',
'href': 'https://openveda.cloud/api/stac/'},
{'rel': 'self',
'type': 'application/json',
'href': 'https://openveda.cloud/api/stac/collections/no2-monthly'}],
'title': 'NO₂',
'assets': {'thumbnail': {'href': 'https://thumbnails.openveda.cloud/no2--dataset-cover.jpg',
'type': 'image/jpeg',
'roles': ['thumbnail'],
'title': 'Thumbnail',
'description': 'Photo by [Mick Truyts](https://unsplash.com/photos/x6WQeNYJC1w) (Power plant shooting steam at the sky)'}},
'extent': {'spatial': {'bbox': [[-180.0, -90.0, 180.0, 90.0]]},
'temporal': {'interval': [['2016-01-01T00:00:00+00:00',
'2022-12-31T00:00:00+00:00']]}},
'license': 'MIT',
'renders': {'dashboard': {'bidx': [1],
'title': 'VEDA Dashboard Render Parameters',
'assets': ['cog_default'],
'rescale': [[0, 15000000000000000]],
'resampling': 'bilinear',
'color_formula': 'gamma r 1.05',
'colormap_name': 'rdbu_r'}},
'providers': [{'url': 'https://disc.gsfc.nasa.gov/',
'name': 'NASA Goddard Earth Sciences Data and Information Services Center',
'roles': ['producer', 'processor']},
{'url': 'https://www.earthdata.nasa.gov/dashboard/',
'name': 'NASA VEDA',
'roles': ['host']}],
'summaries': {'datetime': ['2016-01-01T00:00:00Z', '2023-09-30T00:00:00Z']},
'description': 'Darker colors indicate higher nitrogen dioxide (NO₂) levels and more activity. Lighter colors indicate lower levels of NO₂ and less activity. Missing pixels indicate areas of no data most likely associated with cloud cover or snow.',
'item_assets': {'cog_default': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
'roles': ['data', 'layer'],
'title': 'Default COG Layer',
'description': 'Cloud optimized default layer to display on map'}},
'stac_version': '1.0.0',
'stac_extensions': ['https://stac-extensions.github.io/item-assets/v1.0.0/schema.json',
'https://stac-extensions.github.io/render/v1.0.0/schema.json'],
'dashboard:is_periodic': True,
'dashboard:time_density': 'month'}
Examining the contents of our collection
under summaries
we see that the data is available from January 2015 to December 2022. By looking at the dashboard:time density
we observe that the periodic frequency of these observations is monthly.
# Check total number of items available
= requests.get(f"{STAC_API_URL}/collections/{collection_name}/items?limit=100").json()["features"]
items print(f"Found {len(items)} items")
Found 93 items
This makes sense as there are 7 years between 2016 - 2022, with 12 months per year, meaning 84 records in total.
Below, we’ll provide the max range of values to apply to visualizations of all items in the collection (rescale_values
).
= {
rescale_values "max": 50064805976866816,
"min": -1018382487283302
}
Seeing Rebounds in NO₂
Air pollutants with short lifespans, like NO₂, decreased dramatically with COVID-related shutdowns in the spring of 2020 (see lefthand side map). As the world began to re-open and mobility restrictions eased, travel increased and alongside it NO₂ pollutants. Air quality levels are now returning to pre-pandemic levels (see righthand side map).
Scroll and zoom within the maps below, the side-by-side comparison will follow wherever you explore. Darker purples indicate higher NO₂ levels and more activity. Lighter blues indicate lower levels of NO₂ and less activity.
# We'll import folium to map and folium.plugins to allow mapping side-by-side
import folium
import folium.plugins
# Set initial zoom and map for NO2 Layer
= folium.plugins.DualMap(location=(33.6901, 118.9325), zoom_start=5)
m
# February 2020
= TileLayer(
map_layer_2020 =february_2020_tile["tiles"][0],
tiles="VEDA",
attr=0.8,
opacity
)
map_layer_2020.add_to(m.m1)
# February 2022
= TileLayer(
map_layer_2022 =february_2022_tile["tiles"][0],
tiles="VEDA",
attr=0.8,
opacity
)
map_layer_2022.add_to(m.m2)
m
Summary
In this case study we have successfully visualized how NASA monitors NO₂ emissions from space. By showcasing lockdown (February 2020) and post-lockdown (February 2022) snapshots of air quality side-by-side, we demonstrate how quickly atmospheric NO₂ responds to reductions in emissions and human behavior.