-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.1. texMer
279 lines (232 loc) · 9.65 KB
/
4.1. texMer
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*Author: Afag Rizayeva
Date:11-January-2022
Purpose: 1. Merge the separate exported texture layers into one for each of the chosen second-order texture metrics:
Angular Second Moment
Entropy
Homogeneity
Usage: Convert the code naming in the code to your corresponding Corona image by pressing Ctrl+F twice
and entering "10111040" without quotes in the first line and "your Corona image code" in the second line
Create a geometry corresponding to your region
Then run the code and excuate "RUN" in the Tasks tab to export the results into GLCM folder in your assets
Based on the following code, you should have 6 total processes to execute (two per each second-order texture metric)
Parameters:
assetId: the directory where you store your separate texture layers exported earlier to be merged by this code
geometry:
*/
// Import two Corona images and build the image geometry
var image2 = ee.Image('users/rizayeva/corona_2_5m/DS1011-1040DA_2_5m_JPEG_1band_EPSG32638');
var image3 = ee.Image('users/rizayeva/corona_2_5m/DS1011-1040DF_2_5m_JPEG_1band_EPSG32638');
var geometry10111040 = image2.addBands(image3).geometry();
Map.addLayer(image2, {min: 0, max: 200}, 'DS1011-1040DA', false);
Map.addLayer(image3, {min: 0, max: 200}, 'DS1011-1040DF', false);
Map.addLayer(geometry10111040, {}, 'geometry10111040', false);
// Angular Second Moment for backward-facing camera
var imageVisParam = {bands: ['ds10111040da_asm'], min: 0.015071922070983398, max: 0.06105865647962591, gamma: [1]};
var assetId='users/rizayeva/GLCM_ASM_DA_10111040';
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
var n=assetList.size().getInfo();
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('AngularSecondMomentDA', collection);
// Mosaic the rasters within collection
var angularSecondMoment_DA = collection.mosaic();
print(angularSecondMoment_DA);
// Map.addLayer(angularSecondMoment_DF, imageVisParam, 'angularSecondMoment_DF');
Map.addLayer(angularSecondMoment_DA, imageVisParam, 'angularSecondMoment_DA');
// Export the final texture metric file
Export.image.toAsset({
image: angularSecondMoment_DA,
description: "angularSecondMoment_DA_10111040",
assetId: 'GLCM/angularSecondMoment_DA_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});
// Angular Second Moment for forwaqrd-facing camera
var imageVisParam = {bands: ['ds10111040df_asm'], min: 0.015071922070983398, max: 0.06105865647962591, gamma: [1]};
var assetId='users/rizayeva/GLCM_ASM_DF_10111040';
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
var n=assetList.size().getInfo();
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('AngularSecondMomentDF', collection);
// Mosaic the rasters within collection
var angularSecondMoment_DF = collection.mosaic();
print(angularSecondMoment_DF);
// Map.addLayer(angularSecondMoment_DF, imageVisParam, 'angularSecondMoment_DF');
Map.addLayer(angularSecondMoment_DF, imageVisParam, 'angularSecondMoment_DF');
// Export the final texture metric file
Export.image.toAsset({
image: angularSecondMoment_DF,
description: "angularSecondMoment_DF_10111040",
assetId: 'GLCM/angularSecondMoment_DF_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});
// Entropy for backward-facing camera
var imageVisParam = {bands: ['ds10111040da_ent'], min: 3.0209101473712536, max: 3.9960161288948637, gamma: [1]};
var assetId='users/rizayeva/GLCM_ENT_DA_10111040';
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
var n=assetList.size().getInfo();
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('EntropyDA', collection);
// Mosaic the rasters within collection
var entropy_DA = collection.mosaic();
print(entropy_DA);
// Map.addLayer(entropy_DA, imageVisParam, 'entropy_DA');
Map.addLayer(entropy_DA, imageVisParam, 'entropy_DA');
// Export the final texture metric file
Export.image.toAsset({
image: entropy_DA,
description: "entropy_DA_10111040",
assetId: 'GLCM/entropy_DA_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});
// Entropy for forward-facing camera
var imageVisParam = {bands: ['ds10111040df_ent'], min: 3.0209101473712536, max: 3.9960161288948637, gamma: [1]};
var assetId='users/rizayeva/GLCM_ENT_DF_10111040';
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
var n=assetList.size().getInfo();
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('EntropyDF', collection);
// Mosaic the rasters within collection
var entropy_DF = collection.mosaic();
print(entropy_DF);
// Map.addLayer(entropy_DF, imageVisParam, 'entropy_DF');
Map.addLayer(entropy_DF, imageVisParam, 'entropy_DF');
// Export the final texture metric file
Export.image.toAsset({
image: entropy_DF,
description: "entropy_DF_10111040",
assetId: 'GLCM/entropy_DF_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});
// Homogeneity for backward-facing camera
var imageVisParam = {bands: ['ds10111040da_idm'], min: 0.10173501666498017, max: 0.49671797626021486, gamma: [1]};
var assetId='users/rizayeva/GLCM_HOM_DA_10111040';
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
var n=assetList.size().getInfo();
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('HomogeneityDA', collection);
// Mosaic the rasters within collection
var homogeneity_DA = collection.mosaic();
print(homogeneity_DA);
// Map.addLayer(homogeneity_DA, imageVisParam, 'homogeneity_DA');
Map.addLayer(homogeneity_DA, imageVisParam, 'homogeneity_DA');
// Export the final texture metric file
Export.image.toAsset({
image: homogeneity_DA,
description: "homogeneity_DA_10111040",
assetId: 'GLCM/homogeneity_DA_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});
// Homogeneity for forward-facing camera
var imageVisParam = {bands: ['ds10111040df_idm'], min: 0.10173501666498017, max: 0.49671797626021486, gamma: [1]};
var assetId='users/rizayeva/GLCM_HOM_DF_10111040';
var n=assetList.size().getInfo();
// Make a list that contains all the imagery in the asset directory
var assetList = ee.List(ee.data.getList({'id':assetId}));
// print(assetList);
// Generate an imagery collection that contains all the land cover maps on the list
var listocollection = function(assetList,size){
var col=ee.ImageCollection([]);
for (var i=0; i<size; i++){
var value=ee.Dictionary(assetList.get(i));
var imgID=ee.String(value.get('id')).getInfo();
var imgs=ee.Image(imgID);
col=col.merge(imgs);
}
return col;
};
// Check the number of rasters in collection
var collection=listocollection(assetList,n);
print('HomogeneityDF', collection);
// Mosaic the rasters within collection
var homogeneity_DF = collection.mosaic();
print(homogeneity_DF);
// Map.addLayer(homogeneity_DF, imageVisParam, 'homogeneity_DF');
Map.addLayer(homogeneity_DF, imageVisParam, 'homogeneity_DF');
// Export the final texture metric file
Export.image.toAsset({
image: homogeneity_DF,
description: "homogeneity_DF_10111040",
assetId: 'GLCM/homogeneity_DF_10111040',
scale: 2.5,
region: geometry10111040,
maxPixels:1e13,
});