Repository navigation
Expand file tree
/
Copy pathgee_DEM.js
More file actions
110 lines (93 loc) · 3.23 KB
/
Copy pathgee_DEM.js
File metadata and controls
110 lines (93 loc) · 3.23 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var geometry = /* color: #98ff00 */ee.Geometry.Polygon(
[[[-48.191953460487625, -22.778062290756594],
[-48.191953460487625, -23.947960284540397],
[-46.697812835487625, -23.947960284540397],
[-46.697812835487625, -22.778062290756594]]], null, false);
/***** End of imports. If edited, may not auto-convert in the playground. *****/
// RUBEM ToolKit dataset input process
// Distributed hydrological model
// https://doi.org/10.3390/w14121958
// Documentation and tutorials:
// https://rubem-hydrological.readthedocs.io/en/latest/
// *youtube link*
ee.ImageCollection("COPERNICUS/DEM/GLO30");
//should be define the geometry by the user.
// script to get
// selected area DEM (SRTM 30m resolution)
// GENERAL CONFIGURATION
// select the area of interest
var area = 'geometry';
// specify the start and end date
var start = '2008-01-01';
var end = '2010-01-01';
print("Start Date: ", start);
print("End Date: ", end);
// external
var batch = require('users/fitoprincipe/geetools:batch');
var palettesGeneral = require('users/gena/packages:palettes');
////////////////////////////////////////////////////////
// DIGITAL ELEVATION MODEL
// get the DEM of the area
// change the max elevation according the region (visDem: max: elevation to change)
var dataset = ee.Image('USGS/SRTMGL1_003');
var elevation = dataset.select('elevation');
var clippedDem = elevation.clip(geometry);
var palette = palettesGeneral.kovesi.diverging_rainbow_bgymr_45_85_c67[7];
var visDem = {
min:0,
max: 2000,
palette: palette
};
// center the map
Map.centerObject(geometry, 15);
// add Geometry to map
Map.addLayer(geometry, {}, 'Geometry');
// export DEM to drive
var exportDem = clippedDem.select('elevation');
Export.image.toDrive({
image: exportDem,
description: 'demFile',
folder: 'Gee_project',
fileNamePrefix: 'demFile',
region: geometry,
scale: 30,
maxPixels: 2e10
});
// add DEM to map
Map.addLayer(clippedDem, visDem, 'DEM');
// Add bar Legend
function createColorBar(titleText, palette, min, max) {
// Legend Title
var title = ui.Label({
value: titleText,
style: {fontWeight: 'bold', textAlign: 'center', stretch: 'horizontal'}});
// Colorbar
var legend = ui.Thumbnail({
image: ee.Image.pixelLonLat().select(0),
params: {
bbox: [0, 0, 2000, 500],
dimensions: '200x20',
format: 'png',
min: 0, max: 2000,
palette: palette},
style: {stretch: 'horizontal', margin: '8px 8px', maxHeight: '40px'},
});
// Legend Labels
var labels = ui.Panel({
widgets: [
ui.Label(min, {margin: '4px 10px',textAlign: 'left', stretch: 'horizontal'}),
ui.Label((min+max)/2, {margin: '4px 20px', textAlign: 'center', stretch: 'horizontal'}),
ui.Label(max, {margin: '4px 10px',textAlign: 'right', stretch: 'horizontal'})],
layout: ui.Panel.Layout.flow('horizontal')});
// Create a panel with all 3 widgets
var legendPanel = ui.Panel({
widgets: [title, legend, labels],
style: {position: 'bottom-center', padding: '8px 15px'}
});
return legendPanel;
}
// Call the function to create a colorbar legend
var colorBar = createColorBar('Digital Elevation Model (m)', palette, 0, 2000);
Map.add(colorBar);
// William Vichete