-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGEE_ndwi_Fig4
More file actions
66 lines (65 loc) · 1.94 KB
/
Copy pathGEE_ndwi_Fig4
File metadata and controls
66 lines (65 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var geometry =
/* color: #d63000 */
/* shown: false */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[-94.15359428793933, 44.13547909509888],
[-94.15359428793933, 44.04374674745631],
[-94.0643303719237, 44.04374674745631],
[-94.0643303719237, 44.13547909509888]]], null, false);
/***** End of imports. If edited, may not auto-convert in the playground. *****/
// pre-dam image:
var collection = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
.filterBounds(geometry)
.filterDate('2024-06-07', '2024-06-08')
.select(['B4', 'B3', 'B2', 'B8'])
.median();
// post-dam image:
var collection2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
.filterDate('2024-07-07', '2024-07-08')
.filterBounds(geometry)
.select(['B4', 'B3', 'B2', 'B8'])
.median();
// clip
var clipImage = collection.clip(geometry);
var clipImage2 = collection2.clip(geometry);
// viz
var visualization = {
min: 0,
max: 3000,
bands: ['B4', 'B3', 'B2'],
}
// add to map
Map.addLayer(clipImage, visualization, '6-08')
Map.addLayer(clipImage2, visualization, '7-08')
Map.centerObject(geometry, 12)
// water mask
var ndwi =
clipImage.normalizedDifference(['B3', 'B8']).rename('NDWI');
//var ndwiParams = {min: -1, max: 1, palette:['red', 'yellow', 'green', 'cyan', 'blue']};
var ndwiParams = {min: -1, max: 1, palette:['white', '0096C7', '023E8A']};
Map.addLayer(
ndwi,
ndwiParams,
'NDWI');
// export ndwi image
Export.image.toDrive({
image: ndwi.visualize(ndwiParams),
description: 'image_export',
folder: 'SWOT_geomorph',
region: geometry,
scale: 12
});
// export real color image
//Export.image.toDrive({
//image: clipImage.visualize(visualization),
//description: 'image_export',
//folder: 'SWOT_geomorph',
//region: geometry,
//scale: 12
//});