-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDEM_2_Drive.js
218 lines (178 loc) · 5.41 KB
/
DEM_2_Drive.js
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Map.setOptions("HYBRID");
// Ареа name for naming files for download
var myArea = 'Shulgovka-Elizavetovka';
// geomerty draw on map
// add DEM data
var dataset_SRTM = ee.Image("USGS/SRTMGL1_003");
Map.centerObject(geometry, 8);
print('dataset_SRTM:',dataset_SRTM);
var elevation_SRTM = dataset_SRTM.select(['elevation']);
var slope_SRTM = ee.Terrain.slope(elevation_SRTM);
var aspect_SRTM = ee.Terrain.aspect(elevation_SRTM);
///////////AOI/////////////////////////////////
var elevation = elevation_SRTM ;
var slope = slope_SRTM ;
var aspect = aspect_SRTM ;
var elevationVis = {
min: -1.0,
max: 1100.0,
palette: [
'3ae237', 'b5e22e', 'd6e21f', 'fff705', 'ffd611', 'ffb613', 'ff8b13',
'ff6e08', 'ff500d', 'ff0000', 'de0101', 'c21301', '0602ff', '235cb1',
'307ef3', '269db1', '30c8e2', '32d3ef', '3be285', '3ff38f', '86e26f'
],
};
var slopeVis = {
min: 0,
max: 30.0,
palette: [
'ffffcc', 'ffeda0', 'fed976', 'feb24c',
'fd8d3c', 'fc4e2a', 'e31a1c', 'bd0026', '800026'
],
opacity: 0.75,
};
var aspectVis = {
min: 0,
max: 360.0,
palette: [
'8dd3c7', 'fed9a6', 'fb8072', 'ffffb3'
],
opacity: 1,
};
// Функция фильтрации
function FiltrationImg(img){
var kernel = ee.Kernel.square(150,'meters');
// var kernel = ee.Kernel.circle(3, 'pixels' );
var image1 = img.focal_median({kernel: kernel, iterations: 1});
// Force projection of 30 meters/pixel
var SCALE = 30;
var image2 = image1.focal_mean({kernel: kernel, iterations: 1});
// Force projection of 30 meters/pixel
// Reproject to WGS84 to force the image to be reprojected on load.
// This is just for display purposes, to visualize the input to
// the following operations. The next reproject is sufficient
// to force the computation to occur at native scale.
var image3 = image2.reproject('EPSG:4326', null, SCALE);
return image3;
}
// Define a function to convert from degrees to radians.
function radians(img) {
return img.toFloat().multiply(Math.PI).divide(180);
}
// Define a function to compute a hillshade from terrain data
// for the given sun azimuth and elevation.
function hillshade(az, ze, slope, aspect) {
// Convert angles to radians.
var azimuth = radians(ee.Image(az));
var zenith = radians(ee.Image(ze));
// Note that methods on images are needed to do the computation.
// i.e. JavaScript operators (e.g. +, -, /, *) do not work on images.
// The following implements:
// Hillshade = cos(Azimuth - Aspect) * sin(Slope) * sin(Zenith) +
// cos(Zenith) * cos(Slope)
return azimuth.subtract(aspect).cos()
.multiply(slope.sin())
.multiply(zenith.sin())
.add(
zenith.cos().multiply(slope.cos()));
}
var slope_rad = radians(slope_SRTM);
var aspect_rad = radians(aspect_SRTM);
var hillshade_SRTM = hillshade(315, 60, slope_rad, aspect_rad);
var elevation_filtred = FiltrationImg(elevation);
var slope_filtred = ee.Terrain.slope(elevation_filtred);
var aspect_filtred = ee.Terrain.aspect(elevation_filtred);
var slope_rad_filtred = radians(slope_filtred);
var aspect_rad_filtred = radians(aspect_filtred);
var hillshade_SRTM_filtred = hillshade(315, 60, slope_rad_filtred, aspect_rad_filtred);
Map.addLayer(elevation.clip(geometry), elevationVis, 'Elevation');
Map.addLayer(elevation_filtred.clip(geometry), elevationVis, 'filtred Elevetion', false);
Map.addLayer(aspect.clip(geometry), aspectVis, 'Aspect', false);
Map.addLayer(aspect_filtred.clip(geometry), aspectVis, 'filt_Aspect', false);
Map.addLayer(slope.clip(geometry), slopeVis, 'Slope', false);
Map.addLayer(slope_filtred.clip(geometry), slopeVis, 'filt_Slope', false);
Map.addLayer(hillshade_SRTM.clip(geometry), {}, 'hillshade_SRTM');
Map.addLayer(hillshade_SRTM_filtred.clip(geometry), {}, 'filrted hillshade_SRTM', false);
Export.image.toDrive({
image: elevation.clip(geometry),
description: 'elevation_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
// slope
Export.image.toDrive({
image: slope.clip(geometry),
description: 'slope_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
// aspect
Export.image.toDrive({
image: aspect.clip(geometry),
description: 'aspect_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
// FILTRED
Export.image.toDrive({
image: elevation_filtred.clip(geometry),
description: 'filtred_elevation_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
// slope
Export.image.toDrive({
image: slope_filtred.clip(geometry),
description: 'filtred_slope_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});
// aspect
Export.image.toDrive({
image: aspect_filtred.clip(geometry),
description: 'filtred_aspect_SRTM_'+myArea,
folder: 'GEE_data',
scale: 30,
region: geometry,
crs: 'EPSG:4326',
maxPixels: 1e10,
fileFormat: 'GeoTIFF',
formatOptions: {
cloudOptimized: true
}
});