TNGIC Conference - Automated mapping of surface water in Tennessee using Google Earth Engine

Subscribe to my newsletter and never miss my upcoming articles

This is a conference presentation I presented at the Tennessee Geographic Information Council (TNGIC) Virtual Fall Forum on October 7, 2020.



Install geemap

# Installs geemap package
import subprocess

    import geemap
except ImportError:
    print('geemap package not installed. Installing ...')
    subprocess.check_call(["python", '-m', 'pip', 'install', 'geemap'])

# Checks whether this notebook is running on Google Colab
    import google.colab
    import geemap.eefolium as geemap
    import geemap

# Authenticates and initializes Earth Engine
import ee

Create an interactive map

Map = geemap.Map()

Define region of interest (ROI)

roi = ee.FeatureCollection('TIGER/2018/States') \
    .filter(ee.Filter.eq('NAME', 'Tennessee'))
Map.addLayer(roi, {}, "TN")
Map.centerObject(roi, 7)

Create Landsat timeseries

images = geemap.landsat_timeseries(roi=roi, start_year=1984, end_year=2020, start_date='01-01', end_date='12-31')
first = images.first()

vis_params = {
    'bands': ['NIR', 'Red', 'Green'],
    'min': 0,
    'max': 3000

Map.addLayer(first, vis_params, 'First image')

Calculate Normalized Difference Water Index (NDWI)

ndwi_images = img: img.normalizedDifference(['Green', 'SWIR1']).rename('ndwi'))

ndwi_palette = ['#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858']

first_ndwi = ndwi_images.first()

Map.addLayer(first_ndwi, {'palette': ndwi_palette}, 'First NDWI')

Extract surface water extent

water_images = img:

first_water = water_images.first()

Map.addLayer(first_water, {'palette': ['blue']}, 'First Water')

Calculate surface water areas

def cal_area(img):
    pixel_area = img.multiply(ee.Image.pixelArea()).divide(1e6)
    img_area = pixel_area.reduceRegion(**{
        'geometry': roi.geometry(),
        'reducer': ee.Reducer.sum(),
        'scale': 1000,
        'maxPixels': 1e12
    return img.set({'water_area': img_area})
water_areas =
water_stats = water_areas.aggregate_array('water_area').getInfo()

Plot temporal trend

import matplotlib.pyplot as plt

x = list(range(1984, 2021))
y = [item.get('ndwi') for item in water_stats], y, align='center', alpha=0.5)
# plt.xticks(y_pos, objects)
plt.ylabel('Area (km2)')
plt.title('Surface water dynamics in Tennessee')

No Comments Yet