Google Earth Engine Tutorial: Estimate Urban Green Space with Sentinel-2A
Credit: Youtube Channel “Terra Spatial, Guide on estimating urban green space area and distribution using Sentinel-2A imagery.”
You can see all the tutorials from here: Techgeo Academy.
Urban green space plays a critical role in improving air quality, reducing heat islands, and supporting biodiversity. Google Earth Engine (GEE) provides a powerful platform for analyzing satellite data, including Sentinel-2A, to estimate and monitor urban green space. This tutorial explains how to use GEE to calculate green space using Sentinel-2A data.
Step 1: Set Up Google Earth Engine
Before starting, ensure you have access to the Google Earth Engine platform. Create an account at https://earthengine.google.com. Once logged in, open the Code Editor to begin.
Step 2: Load Sentinel-2A Data
Use the Sentinel-2A Surface Reflectance (S2_SR) dataset. Filter the data by date, location, and cloud coverage. Examples in JavaScript (GEE’s programming language):
var dataset = ee.ImageCollection("COPERNICUS/S2_SR")
.filterDate('2022-01-01', '2022-12-31')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))
.filter(ee.Filter.geometry(geometry));
Step 3: Preprocess the Data
Preprocess the images by selecting key bands (e.g., B4, B3, B2 for RGB; B8 for near-infrared) and applying cloud masking.
var image = dataset.select(['B4', 'B3', 'B2', 'B8']).median();
var cloudMask = ee.Algorithms.Landsat.getCloudMask(image);
var maskedImage = image.updateMask(cloudMask);
Step 4: Calculate the Green Space Index
Compute the Normalized Difference Vegetation Index (NDVI) to identify green areas:
var ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI');
Apply a threshold to NDVI values (e.g., above 0.35) to classify vegetation.
var greenSpace = ndvi.gt(0.35);
Step 5: Visualize and Export Results
Display the green space map on the map and export the data as a GeoTIFF or CSV.
Map.addLayer(greenSpace, {palette: ['green']}, 'Green Space');
Export.image.toDrive({
image: greenSpace,
description: 'UrbanGreenSpace',
folder: 'GEE_Exports',
fileName: 'green_space',
region: geometry,
scale: 10
});
FAQ
What is the most accurate index for urban green space?
The NDVI is commonly used for vegetation analysis, but other indices like the Normalized Difference Water Index (NDWI) or normalized difference built-up index (NDBI) can complement the results.
How do I select the right cloud coverage threshold?
For urban areas, 20% cloud coverage is typical. Adjust this based on your study area and data quality requirements.
Can I use other satellites with this method?
Yes! Replace the dataset with others like Landsat 8 or 9. The workflow remains similar, but specific bands and preprocessing steps may differ.
How do I export the green space data?
Use Export.image.toDrive() for GeoTIFFs or Export.table.toDrive() for polygon data. Ensure the region parameter matches your study area.






