-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgee_code.js
More file actions
71 lines (57 loc) · 1.68 KB
/
gee_code.js
File metadata and controls
71 lines (57 loc) · 1.68 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
67
68
69
70
71
//var geometry = draw your rectangle/polygon.
Map.centerObject(geometry,12);
function maskS2clouds(image) {
var qa = image.select('QA60');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
var dataset = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
.filterDate('2017-01-01', '2020-01-30')
.filterBounds(geometry)
// Pre-filter to get less cloudy granules.
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',1))
.map(maskS2clouds);
var demdata = ee.ImageCollection("COPERNICUS/DEM/GLO30")
.select('DEM')
.filterBounds(geometry);
var elevationVis = {
min: 0.0,
max: 1000.0,
palette: ['0000ff','00ffff','ffff00','ff0000','ffffff'],
};
var expImg = dataset.median()
print(expImg)
var visualization = {
min: 0.0,
max: 0.3,
bands: ['B4', 'B3', 'B2'],
};
print(demdata.first())
Map.addLayer(demdata.mean(), elevationVis, 'DEM');
Map.addLayer(expImg, visualization, 'RGB');
/**/
//Image export
Export.image.toDrive({
image: expImg.select(["B4","B3","B2"]),
description: 'Faroe',
folder: 'ee_demos',
region: geometry,
scale: 30,
crs: 'EPSG:4326',
maxPixels: 1e13
});
//DEM export
Export.image.toDrive({
image: demdata.mean(),
description: 'Faroe_DEM',
folder: 'ee_demos',
region: geometry,
scale: 30,
crs: 'EPSG:4326',
maxPixels: 1e13
});