Mapping water in the San Roque Dam

Constructed in 1998

Copy and run the code below. Zoom in to the San Roque Dam and investigate the before and after images.


// import images
var imgBefore = ee.Image("LANDSAT/LT05/C01/T1_SR/LT05_116049_19971022");
var imgAfter = ee.Image("LANDSAT/LC08/C01/T1_SR/LC08_116049_20160213");

// set threshold
var threshold = 0.3

// calculate ndwi before dam construction
var ndwiBefore = imgBefore.normalizedDifference(["B2","B4"])
var ndwiBefore = ndwiBefore.mask(ndwiBefore.gt(threshold))

// calculate ndwi after dam construction
var ndwiAfter = imgAfter.normalizedDifference(["B3","B5"])
var ndwiAfter = ndwiAfter.mask(ndwiAfter.gt(threshold))

// add images as true color
Map.addLayer(ee.Image(imgBefore),{bands:"B3,B2,B1",min:0,max:3000},"Before dam")
Map.addLayer(ee.Image(imgAfter),{bands:"B4,B3,B2",min:0,max:3000},"After dam")

// add water maps
Map.addLayer(ndwiBefore,{palette:"blue"},"ndwi Before")
Map.addLayer(ndwiAfter,{palette:"blue"},"ndwi After")

link

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s