forked from montemisma/EScore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGEEscript_withOSMquery
644 lines (465 loc) · 25.8 KB
/
GEEscript_withOSMquery
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
// Supplement to the paper: "Breaking the ESG rating divergence: an open geospatial framework
// for environmental scores" by Rossi et al.
// Script compiled by Cristian Rossi and Jack Hepper.
// Steps you need to take:
// STEP 1:
// Input a shapefile of the area to investigate. Click Assets (on left) -> New -> Upload.
// Once processing has finished, import from Assets to script, and rename table to ald.
// STEP 2:
// Define the variables below. Input the start dates in 'YYYY-MM-DD' format. Input the
// monitoring period length of each period as a number of weeks. (4 is suggested.)
var firstPeriodStarts = '2020-08-01';
var secondPeriodStarts = '2022-08-01';
var monitoringPeriodWeeks = 4;
// STEP 3:
// Input variables on line 473 and 474 (Important!).
// STEP 4 (FINAL):
// Run script and use outputs under Console (on right) and Layers (below) to derive E-Score for
// asset. Note comments on lines 318, 375, and 451 to assist you in interpretation. An option to
// generate an overpass turbo script for the OpenStreetMap analyses is also presented to the right
// of the map, if you have run the script including OSM integration. Inspect CH4 and Dynamic World
// (Classified Composite) layers closely; if there are too many NULL pixels (more than a few in
// Dynamic World and more than half of the AoI area for CH4), adjust monitoring periods until
// layers draw satisfactorily.
// **************************************************************************************** //
// ************************** E Land Cover Change Score *********************************** //
// **************************************************************************************** //
// Script to compute newly anthropogenic areas from two land cover products
// ---------------------------------------------------------------------------------------- //
// Display the shapefile into the interactive map
// Centre the view.
Map.centerObject(ald);
// Define styling and determine the color of the shapefile (hex starting
// with '00' denotes full transparency).
var styling = {color: 'red', fillColor: '00000000'};
Map.addLayer(ald.style(styling), '', 'AoI');
// --------------------------------------------------------------------------------------- //
// Dates
// First Monitoring Period
var startDate = firstPeriodStarts;
var endDate = ee.Date(startDate).advance(monitoringPeriodWeeks, 'week');
print('First monitoring period:', startDate, 'to',
(ee.Date(endDate).format()).slice(0,10));
// Second Monitoring Period
var startDate2 = secondPeriodStarts;
var endDate2 = ee.Date(startDate2).advance(monitoringPeriodWeeks, 'week');
print('Second monitoring period:', startDate2, 'to',
(ee.Date(endDate2).format()).slice(0,10));
// Creating multi-temporal composites from Dynamic World
// Filtering the Dynamic World NRT collection by monitoring period and location
var dwCollectionOne = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filter(ee.Filter.date(startDate, endDate))
.filter(ee.Filter.bounds(ald));
// Creating a mode composite from the temporally- and spatially-subset Dyanmic World collection
var classification = dwCollectionOne.select('label');
var dwComposite = classification.reduce(ee.Reducer.mode());
var dwVisParams = {
min: 0,
max: 8,
palette: ['#419BDF', '#397D49', '#88B053', '#7A87C6',
'#E49635', '#DFC35A', '#C4281B', '#A59B8F', '#B39FE1']
};
// Clipping the composite and adding it to the map
var title1 = ee.String('Classified Composite for Period Starting ')
.cat(startDate.slice(0,4));
Map.addLayer(dwComposite.clip(ald), dwVisParams, title1.getInfo());
// Creating a Top-1 Probability Hillshade visualisation
// See developers.google.com/earth-engine/tutorials/community/introduction-to-dynamic-world-pt-1
// for explanation
var probabilityBands = [
'water', 'trees', 'grass', 'flooded_vegetation', 'crops',
'shrub_and_scrub', 'built', 'bare', 'snow_and_ice'
];
// Select probability bands
var probabilityCol = dwCollectionOne.select(probabilityBands);
// Create a multi-band image with the average pixel-wise probability
// for each band across the time-period
var meanProbability = probabilityCol.reduce(ee.Reducer.mean());
// Composites have a default projection that is not suitable
// for hillshade computation.
// Set a EPSG:3857 projection with 10m scale
var projection = ee.Projection('EPSG:3857').atScale(10);
var meanProbability = meanProbability.setDefaultProjection(projection);
// Creating the Top1 Probability Hillshade visualisation
var top1Probability = meanProbability.reduce(ee.Reducer.max());
var top1Confidence = top1Probability.multiply(100).int();
var hillshade = ee.Terrain.hillshade(top1Confidence).divide(255);
var rgbImage = dwComposite.visualize(dwVisParams).divide(255);
var probabilityHillshade = rgbImage.multiply(hillshade);
var hillshadeVisParams = {min:0, max:0.8};
var probabilityHillshadeTitle1 = ee.String('Probability Hillshade for Period Starting ')
.cat(startDate.slice(0,4));
Map.addLayer(probabilityHillshade.clip(ald),
hillshadeVisParams, probabilityHillshadeTitle1.getInfo());
// Creating multi-temporal composites from Dynamic World: Second period
// Filter the Dynamic World NRT collection by monitoring period and location
var dwCollectionTwo = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filter(ee.Filter.date(startDate2, endDate2))
.filter(ee.Filter.bounds(ald));
// Create a mode composite from the temporally- and spatially-subset Dyanmic World collection
var classification = dwCollectionTwo.select('label');
var dwComposite2 = classification.reduce(ee.Reducer.mode());
var dwVisParams = {
min: 0,
max: 8,
palette: ['#419BDF', '#397D49', '#88B053', '#7A87C6',
'#E49635', '#DFC35A', '#C4281B', '#A59B8F', '#B39FE1']
};
// Clip the composite and add it to the Map
var title2 = ee.String('Classified Composite for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(dwComposite2.clip(ald), dwVisParams, title2.getInfo());
// Create a Top-1 Probability Hillshade Visualization
var probabilityBands = [
'water', 'trees', 'grass', 'flooded_vegetation', 'crops',
'shrub_and_scrub', 'built', 'bare', 'snow_and_ice'
];
// Select probability bands
var probabilityCol2 = dwCollectionTwo.select(probabilityBands);
// Create a multi-band image with the average pixel-wise probability
// for each band across the time-period
var meanProbability2 = probabilityCol2.reduce(ee.Reducer.mean());
// Composites have a default projection that is not suitable
// for hillshade computation.
// Set a EPSG:3857 projection with 10m scale
var projection = ee.Projection('EPSG:3857').atScale(10);
var meanProbability2 = meanProbability2.setDefaultProjection(projection);
// Create the Top1 Probability Hillshade
var top1Probability2 = meanProbability2.reduce(ee.Reducer.max());
var top1Confidence2 = top1Probability2.multiply(100).int();
var hillshade2 = ee.Terrain.hillshade(top1Confidence2).divide(255);
var rgbImage2 = dwComposite2.visualize(dwVisParams).divide(255);
var probabilityHillshade2 = rgbImage2.multiply(hillshade2);
var hillshadeVisParams = {min:0, max:0.8};
var probabilityHillshadeTitle2 = ee.String('Probability Hillshade for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(probabilityHillshade2.clip(ald),
hillshadeVisParams, probabilityHillshadeTitle2.getInfo());
// // ----------------------------------------------------------------------- //
// // Detect changes from natural to anthropogenic ------------------------- //
// anthropogenic
//built areas
var dw_built = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('built');
var beforeDw_built = dw_built.filterDate(startDate, endDate).mean();
var afterDw_built = dw_built.filterDate(startDate2, endDate2).mean();
// bare ground
var dw_bare = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('bare');
var beforeDw_bare = dw_bare.filterDate(startDate, endDate).mean();
var afterDw_bare = dw_bare.filterDate(startDate2, endDate2).mean();
// crops
var dw_crops = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('crops');
var beforeDw_crops = dw_crops.filterDate(startDate, endDate).mean();
var afterDw_crops = dw_crops.filterDate(startDate2, endDate2).mean();
// natural
//water
var dw_water = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('water');
var beforeDw_water = dw_water.filterDate(startDate, endDate).mean();
var afterDw_water = dw_water.filterDate(startDate2, endDate2).mean();
// trees
var dw_trees = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('trees');
var beforeDw_trees = dw_trees.filterDate(startDate, endDate).mean();
var afterDw_trees = dw_trees.filterDate(startDate2, endDate2).mean();
// grass
var dw_grass = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('grass');
var beforeDw_grass = dw_grass.filterDate(startDate, endDate).mean();
var afterDw_grass = dw_grass.filterDate(startDate2, endDate2).mean();
//flooded_vegetation
var dw_flooded_vegetation = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('flooded_vegetation');
var beforeDw_flooded_vegetation = dw_flooded_vegetation.filterDate(startDate, endDate).mean();
var afterDw_flooded_vegetation = dw_flooded_vegetation.filterDate(startDate2, endDate2).mean();
// shrub_and_scrub
var dw_shrub_and_scrub = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('shrub_and_scrub');
var beforeDw_shrub_and_scrub = dw_shrub_and_scrub.filterDate(startDate, endDate).mean();
var afterDw_shrub_and_scrub = dw_shrub_and_scrub.filterDate(startDate2, endDate2).mean();
// snow and ice
var dw_snow_and_ice = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1')
.filterBounds(ald)
.select('snow_and_ice');
var beforeDw_snow_and_ice = dw_snow_and_ice.filterDate(startDate, endDate).mean();
var afterDw_snow_and_ice = dw_snow_and_ice.filterDate(startDate2, endDate2).mean();
// Selecting pixels that were water and are now anthropogenic
var newAntro_fromWater = beforeDw_water.gt(0.35).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.35)).or(afterDw_crops.gt(0.35)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro_fromWater.clip(ald), changeVisParams, 'New Anthropogenic from Water');
// Trees to Anthro
var newAntro_fromTrees = beforeDw_trees.gt(0.35).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.35)).or(afterDw_crops.gt(0.35)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro_fromTrees.clip(ald), changeVisParams, 'New Anthropogenic from Trees');
// Grass to Anthro
var newAntro_fromGrass = beforeDw_grass.gt(0.35).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.35)).or(afterDw_crops.gt(0.35)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro_fromGrass.clip(ald), changeVisParams, 'New Anthropogenic from Grass');
// Flooded Vegetation to Anthro
var newAntro_fromFlood = beforeDw_flooded_vegetation.gt(0.35).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.35)).or(afterDw_crops.gt(0.35)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro_fromFlood.clip(ald), changeVisParams, 'New Anthropogenic from Flooded Vegetation');
// Shrubs to Anthro
var newAntro_fromShrubs = beforeDw_shrub_and_scrub.gt(0.35).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.35)).or(afterDw_crops.gt(0.35)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro_fromShrubs.clip(ald), changeVisParams, 'New Anthropogenic from Shrubs');
// Display all new anthropogenic areas
var newAntro = (beforeDw_grass.gt(0.35).or(beforeDw_trees.gt(0.35)).or(beforeDw_water.gt(0.35)).or(beforeDw_flooded_vegetation.gt(0.35)).or(beforeDw_shrub_and_scrub.gt(0.35))).and((afterDw_built.gt(0.35)).or(afterDw_bare.gt(0.3)).or(afterDw_crops.gt(0.3)));
var changeVisParams = {min: 0, max: 1, palette: ['white', 'red']};
Map.addLayer(newAntro.clip(ald), changeVisParams, 'New Anthropogenic areas');
// ------------------------------------------------------------------------------ //
// ---- Visualisation check ------------------------------------------------------
var s2 = ee.ImageCollection('COPERNICUS/S2')
.filterBounds(ald)
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 35));
var beforeS2 = s2.filterDate(startDate, endDate).median();
var afterS2 = s2.filterDate(startDate2, endDate2).median();
// Adjust stretch (min / max values) if images are too washed out; alternatively
// use settings accessible from layer menu on map
// Sentinel image one (earlier)
var s2VisParams1 = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};
var s2VisTitle1 = ee.String('Sentinel-2 Image for Period Starting ')
.cat(startDate.slice(0,4));
Map.addLayer(beforeS2.clip(ald), s2VisParams1, s2VisTitle1.getInfo());
// Sentinel image two (later)
var s2VisParams2 = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};
var s2VisTitle2 = ee.String('Sentinel-2 Image for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(afterS2.clip(ald), s2VisParams2, s2VisTitle2.getInfo());
Map.addLayer(newAntro.selfMask().clip(ald), changeVisParams, 'New Anthropogenic areas (Masked)');
// ------------------------------------------------------------------------------ //
// -------------- Find the percentage of change --------------------------------- //
var builtArea = dwComposite.eq(6).clip(ald);
var builtArea = builtArea.rename(['built_area']);
// Count all pixels.
var statsTotal = builtArea.reduceRegion({
reducer: ee.Reducer.count(),
geometry: ald,
scale: 10,
maxPixels: 1e10
});
var totalPixels = statsTotal.get('built_area');
print('Total Pixels in AoI:', totalPixels);
// Mask 0 pixel values and count remaining pixels.
var builtAreaMasked = newAntro.selfMask().clip(ald);
var statsMasked = builtAreaMasked.reduceRegion({
reducer: ee.Reducer.count(),
geometry: ald,
scale: 10,
maxPixels: 1e10
});
var builtAreaPixels = statsMasked.get('grass'); //takes the name of the first
print('Total pixels that changed from Natural to Anthropogenic in AoI:', builtAreaPixels);
var fraction = (ee.Number(builtAreaPixels).divide(totalPixels))
.multiply(100);
print('Percentage of AoI that changed from Natural to Anthropogenic:', fraction.format('%.2f'));
// **************************************************************************************** //
// ***************************** E Hydrology Score **************************************** //
// **************************************************************************************** //
// Note: The most severe algal blooms may be misclassified by Dynamic World as flooded vegetation.
// Additionally, river islands and small land features adjacent to waterways can sometimes be detected
// as water. In both cases, this can result in pollution false negatives / positives. Be sure to
// manually inspect the pollution hotspots and wider area in the Sentinel-2 visualisation layer to
// double check validity of output.
// 1. Extract Water Bodies from LCCs
// Extract the Water class.
var WaterArea1 = dwComposite.eq(0);
var WaterArea2 = dwComposite2.eq(0);
// 2. Mask Water areas
var WaterMasked1 = WaterArea1.clip(ald).updateMask(WaterArea1.eq(1));
var WaterMasked2 = WaterArea2.clip(ald).updateMask(WaterArea2.eq(1));
var waterMaskedTitle1 = ee.String('Water Areas for Period Starting ')
.cat(startDate.slice(0,4));
Map.addLayer(WaterMasked1, {palette:['cyan']}, waterMaskedTitle1.getInfo());
var waterMaskedTitle2 = ee.String('Water Areas for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(WaterMasked2, {palette:['cyan']}, waterMaskedTitle2.getInfo());
// 3. Compute NDCI
var S2masked1 = beforeS2.updateMask(WaterArea1.eq(1));
var S2masked2 = afterS2.updateMask(WaterArea2.eq(1));
function ndci_f(img){
//water mask
var ndci = img.normalizedDifference(['B5', 'B4']).rename('NDCI');
return img.addBands(ndci);
}
var before_NDCI = ndci_f(S2masked1);
var after_NDCI = ndci_f(S2masked2);
// print(IMG.get('CLOUDY_PIXEL_PERCENTAGE'))
var viz = {min:0.1,max:0.4,palette:['cyan','orange','red']};
var ndciTitle1 = ee.String('NDCI for Period Starting ')
.cat(startDate.slice(0,4));
Map.addLayer(before_NDCI.select('NDCI'),viz,ndciTitle1.getInfo());
var ndciTitle2 = ee.String('NDCI for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(after_NDCI.select('NDCI'),viz,ndciTitle2.getInfo());
// Find high-values of NDCI
var before_NDCI_mask = before_NDCI.select('NDCI').gt(0.1);
var after_NDCI_mask = after_NDCI.select('NDCI').gt(0.1);
var before_NDCI_mask_title = ee.String('NDCI (Masked) for Period Starting ')
.cat(startDate.slice(0,4));
var after_NDCI_mask_title = ee.String('NDCI (Masked) for Period Starting ')
.cat(startDate2.slice(0,4));
Map.addLayer(before_NDCI_mask,{palette:['black','red']},before_NDCI_mask_title.getInfo());
Map.addLayer(after_NDCI_mask,{palette:['black','red']},after_NDCI_mask_title.getInfo());
// Overlay with Hydroshed to figure out drainage direction
var wwf = ee.Image('WWF/HydroSHEDS/03DIR');
var drainageDirection = wwf.select('b1').clip(ald);
var drainageDirectionVis = {
min: 1.0,
max: 128.0,
palette: [
'000000', '023858', '006837', '1a9850', '66bd63', 'a6d96a', 'd9ef8b',
'ffffbf', 'fee08b', 'fdae61', 'f46d43', 'd73027'
],
};
Map.addLayer(drainageDirection, drainageDirectionVis, 'Drainage Direction (see line 451 for instruct)');
// Instructions for use:
// 1) Use the marker tool (📍) in the map view to define multiple points along a drainage basin.
// 2) Click the stop drawing tool (🤚).
// 3) Switch to the Inspector panel (on right).
// 4) Click the pushpins you have placed on the map to inspect their values.
// To interpret the values, consult:
// developers.google.com/earth-engine/datasets/catalog/WWF_HydroSHEDS_03DIR#bands
//Clean water: NDCI values close to zero or slightly negative (around -0.1 to 0.1)
//Moderately polluted water: NDCI values between 0.1 and 0.4
//Highly polluted water: NDCI values above 0.4
// // **************************************************************************************** //
// // ************************** E Global Emissions Score ************************************ //
// // **************************************************************************************** //
// Important! Manually input dates to define dateRangeStart and dateRangeEnd, ensuring they do not fall
// between 2022-07-26 and 2022-08-31, due to a provider outage during this period. The dates input
// should correspond exactly to your second (later) monitoring period, or a close time period of
// equivalent length if your second monitoring period falls within the prohibited dates.
var dateRangeStart = '2022-09-01'; // add your number of weeks (default 4) to the date to the left to calculate the date below
var dateRangeEnd = '2022-10-01'; // check neither date falls within prohibited period
var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_CH4')
.select('CH4_column_volume_mixing_ratio_dry_air_bias_corrected')
.filterDate(dateRangeStart, dateRangeEnd);
var band_viz = {
min: 1800,
max: 2000,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var methaneSite = collection.mean().clip(ald);
Map.addLayer(methaneSite, band_viz, 'S5P CH4');
// Compute mean methane emission within site boundary
var meanMethane = methaneSite.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: ald,
scale: 1000 //1km
});
// Print result to console
print('Mean methane emission over site:', meanMethane); // low: <1800, mid: 1800-2000, high: >2000
///////////////////
var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_SO2')
.select('SO2_column_number_density')
.filterDate(dateRangeStart, dateRangeEnd);
var band_viz = {
min: 0.0,
max: 0.001,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var sulphurSite = collection.mean().clip(ald);
Map.addLayer(sulphurSite, band_viz, 'S5P SO2');
// Compute mean sulphur dioxide emission within site boundary
var meanSulphur = sulphurSite.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: ald,
scale: 1000 //1km
});
// Print result to console
print('Mean sulfur dioxide emission over site:', meanSulphur); // low: <0.001 mid:0.001-0.01 high:>0.1
/////////
var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
.select('tropospheric_NO2_column_number_density')
.filterDate(dateRangeStart, dateRangeEnd);
var band_viz = {
min: 0,
max: 0.0002,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var nitrogenSite = collection.mean().clip(ald);
Map.addLayer(nitrogenSite, band_viz, 'S5P N02');
// Compute mean nitrogen dioxide emission within site boundary
var meanNitrogen = nitrogenSite.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: ald,
scale: 1000 //1km
});
// Print result to console
print('Mean nitrogen dioxide emission over site:', meanNitrogen); // low: 0 - 0.0002 mid:0.0002 - 0.0005 high:>0.0005
///////
var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_CO')
.select('CO_column_number_density')
.filterDate(dateRangeStart, dateRangeEnd);
var band_viz = {
min: 0,
max: 0.05,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
var carbonSite = collection.mean().clip(ald);
Map.addLayer(carbonSite, band_viz, 'S5P CO');
// Compute mean carbon monoxide emission within site boundary
var meanCarbon = carbonSite.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: ald,
scale: 1000 //1km
});
// Print result to console
print('Mean carbon monoxide emission over site:', meanCarbon); // low: 0 - 0.01 mid:0.01 - 0.05 high:>0.05
// **************************************************************************************** //
// ******************************** OpenStreetMap ***************************************** //
// **************************************************************************************** //
// Extract AoI coordinates
var AoI = ee.FeatureCollection(ald).geometry();
var myCoordinates = AoI.coordinates();
// Convert coordinates to a client-side array
var coordinatesArray = myCoordinates.getInfo();
// Flip lon/lat pairs to lat/lon within each pair and extract as string
var numbersStringComma = coordinatesArray.map(function(coord) {
var flippedPair = coord.map(function(num) {
return [num[1], num[0]];
});
return flippedPair.join(',');
}).join(',');
// Duplicate and process string(s) for incorporation into URL paramaters
var poly = numbersStringComma.replace(/,/g, '%20');
var polyBoundary = numbersStringComma.replace(/,/g, '%2C');
// URL parameterisation
var urlFrag1 = "https://overpass-turbo.eu/?Q=%2F%2A+Supplement+to+the+paper%3A+%22Breaking+the+ESG+rating+divergence%3A+an+open+geospatial+framework+for+environmental+scores%22+by+Rossi+et+al.%0D%0A%0D%0AAoI+polygon+information+auto-imported+from+GEE+script.%0D%0A%0D%0AWhat+you+need+to+do%3A%0D%0A%0D%0ASTEP+1%3A+Define+variables+below+to+describe+what+to+check+AoI+for+and+how+far+to+buffer+around+it.%0D%0A%0D%0A%7B%7Btag%3Dprotected_area%7D%7D+Add+protected_area+%2F+nature_reserve+%2F+wetland%0D%0A%7B%7Bbuffer%3D0%7D%7D+Define+buffer+around+AoI+in+metres%0D%0A%0D%0ASTEP+2%3A+Click+%27Run%27.+Then+click+%27zoom+to+data%27+%28the+%F0%9F%94%8D+icon%29.%0D%0A%0D%0ASTEP+3+%28FINAL%29%3A+Inspect+output.+Areas+drawn+intersect+with+the+AoI+%28plus+buffer%2C+if+greater+than+zero%29.+If+nothing+is+drawn%2C+that+means+there+is+no+element+within+%28buffer+meters+of%29+the+AoI+with+the+tag+value.%0D%0A%0D%0A%7B%7Bpoly%3D";
var urlFrag2 = "%7D%7D%0D%0A%7B%7Bpolyboundary%3D";
var urlFrag3 = "%7D%7D%0D%0A%0D%0A%7B%7Bstyle%3A%0D%0A%09way%2C+relation%2C+node%0D%0A%09%7B+color%3Ared%3B+fill-color%3Awhite%3B+%7D%0D%0A%7D%7D%0D%0A%0D%0ANB+only+looks+for+ways%2Frelations+%28wr%29%2C+not+nodes+-+as+they+are+not+deemed+relevant+for+the+E-Score+analysis.+%2A%2F%0D%0A%0D%0Awr%5B%22boundary%22%3D%22%7B%7Btag%7D%7D%22%5D%28poly%3A%22%7B%7Bpoly%7D%7D%22%29%3B%28._%3B%3E%3B%29%3Bout+body%3B%0D%0A%0D%0Awr%5B%22boundary%22%3D%22%7B%7Btag%7D%7D%22%5D%28around%3A%7B%7Bbuffer%7D%7D%2C%7B%7Bpolyboundary%7D%7D%29%3B%28._%3B%3E%3B%29%3Bout+body%3B%0D%0A+++%0D%0Awr%5B%22leisure%22%3D%22%7B%7Btag%7D%7D%22%5D%28poly%3A%22%7B%7Bpoly%7D%7D%22%29%3B%28._%3B%3E%3B%29%3Bout+body%3B%0D%0A+++%0D%0Awr%5B%22leisure%22%3D%22%7B%7Btag%7D%7D%22%5D%28around%3A%7B%7Bbuffer%7D%7D%2C%7B%7Bpolyboundary%7D%7D%29%3B%28._%3B%3E%3B%29%3Bout+body%3B%0D%0A%0D%0Awr%5B%22natural%22%3D%22%7B%7Btag%7D%7D%22%5D%28poly%3A%22%7B%7Bpoly%7D%7D%22%29%3B%28._%3B%3E%3B%29%3Bout+body%3B%0D%0A+++%0D%0Awr%5B%22natural%22%3D%22%7B%7Btag%7D%7D%22%5D%28around%3A%7B%7Bbuffer%7D%7D%2C%7B%7Bpolyboundary%7D%7D%29%3B%28._%3B%3E%3B%29%3Bout+body%3B";
var url = urlFrag1 + poly + urlFrag2 + polyBoundary + urlFrag3;
// Add panel to right of map
var panel = ui.Panel({
style: {
width: '115px',
}
});
ui.root.insert(1, panel);
// Add link to overpass turbo script
var link = ui.Label('Generate overpass turbo script for AoI', {
fontWeight: 'bold',
backgroundColor: 'fffb91'
},url);
panel.add(link);
// Add warning text (can malform on MS Edge because of Edge's very low URL length
// limit - as polygon info is passed via URL this causes issues)
var text1 = ui.Label('(For OpenStreetMap analyses)', {
fontSize: '11.5px'
});
panel.add(text1);
var text2 = ui.Label('Please note: overpass turbo script generation assumes AoI is one solid polygon. If AoI is multiple polygons or a polygon with an internal void, script will produce incorrect output. Script can malform on Microsoft Edge; a different browser is recommended.', {
fontSize: '10px'
});
panel.add(text2);