Google Earth Engine Tutorial: Import and Visualize Global NO2 Data
Credit: Youtube Channel “Terra Spatial, Tutorial on importing and analyzing global nitrogen dioxide concentration data from Sentinel-5P.”
You can see all the tutorials from here: Techgeo Academy.
Getting Started with Google Earth Engine
Google Earth Engine (GEE) is a powerful platform for analyzing and visualizing geospatial data. To begin, ensure you have a Google account and access to the GEE code editor. Navigate to the GEE website and open the Code Editor to start coding.
Importing Global NO2 Data
To import NO2 data, use the GEE dataset API. The following code fetches data from the “COPERNICUS/S5P/NRTI/L3_NO2” collection:
var no2Dataset = ee.ImageCollection("COPERNICUS/S5P/NRTI/L3_NO2");
var no2Image = no2Dataset.filterDate('2023-01-01', '2023-01-31').first();
This example selects the latest image within January 2023. Adjust the date range as needed.
Visualizing NO2 Data
Visualize the data using a color palette. The following code creates a map and displays the NO2 column:
Map.centerObject(no2Image, 5);
var no2VisParam = { min: 0, max: 0.5, palette: ['black', 'blue', 'purple', 'green', 'yellow', 'red'] };
Map.addLayer(no2Image.select('tropospheric_NO2_column'), no2VisParam, 'NO2 Column');
The select method isolates the NO2 band, and the palette defines the color gradient for visualization.
Enhancing the Visualization
To add a legend and labels, use the following code:
var palette = ['white', 'yellow', 'orange', 'red'];
var visParams = { min: 0, max: 0.5, palette: palette };
var legend = ui.widget.Panel({
style: { position: 'bottom-left', padding: '8px 12px' }
});
var legendTitle = ui.widget.Label('NO2 Concentration (mol/mΒ²)', { fontSize: '14px', fontWeight: 'bold' });
legend.add(legendTitle);
for (var i = 0; i < palette.length; i++) {
var color = palette[i];
var label = ui.widget.Label(color, { backgroundColor: color, color: 'black', padding: '4px', margin: '4px' });
legend.add(label);
}
Map.add(legend);
This creates a color bar legend for the NO2 data. Adjust the min and max values for better representation.
Exporting the Visualization
To export the visualization as an image, use the image export function:
Export.image.toDrive({
image: no2Image.select('tropospheric_NO2_column'),
description: 'NO2_Data_Export',
folder: 'GEE_Exports',
fileNamePrefix: 'NO2_Map',
region: no2Image.geometry(),
scale: 1000,
maxPixels: 1e8
});
Choose the desired output format and adjust parameters like scale and region to fit your needs.
FAQ
- What is NO2 data in GEE?
NO2 data represents nitrogen dioxide concentrations in the atmosphere, useful for tracking air pollution and environmental monitoring.
- Why use the COPERNICUS/S5P dataset?
This dataset provides high-resolution, daily NO2 measurements from the Sentinel-5P satellite, ideal for global-scale analysis.
- How do I handle missing data or errors?
If data is unavailable for a specific date, use filter(ee.Filter.eq('system:index', 'specific_date')) to find valid entries.
- Can I customize the color palette?
Absolutely. Modify the palette array in the visualization parameters to match your preferences.
- How to visualize time-series data?
Use no2Dataset.toList to iterate over images, then create a loop to display each date's NO2 levels.