-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVIIRS_scraping
120 lines (107 loc) · 4.82 KB
/
VIIRS_scraping
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
var gef_merge = ee.FeatureCollection('''FILL IN FEATURECOLLECTION''');
//print(gef_merge);
//Map.addLayer(gef_merge, {color: 'purple'}, 'gef_merge');
Map.addLayer(gef_merge, {color: 'green'}, 'gef_merge');
var VIIRS_nighttimeLights = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG').filter(ee.Filter.date('2014-01-01', '2022-01-01')).select('avg_rad');
var VIIRS_nighttimeLights_func_2014 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2014-01-01', '2022-01-01'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2014: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2015 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2015-01-01', '2015-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2015: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2016 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2016-01-01', '2016-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2016: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2017 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2017-01-01', '2017-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2017: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2018 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2018-01-01', '2018-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2018: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2019 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2019-01-01', '2019-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2019: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2020 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2020-01-01', '2020-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2020: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_func_2021 = function(feature) {
var collection = ee.ImageCollection(VIIRS_nighttimeLights.filterDate('2021-01-01', '2021-12-31'));
var clipped = collection.mean().clip(feature.geometry());
var meanDictionary = clipped.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: feature.geometry(),
scale: 30,
maxPixels: 1e9
});
return feature.set({avg_rad_2021: meanDictionary.get('avg_rad')})
};
var VIIRS_nighttimeLights_2014 = gef_merge.map(VIIRS_nighttimeLights_func_2014);
var VIIRS_nighttimeLights_2015 = VIIRS_nighttimeLights_2014.map(VIIRS_nighttimeLights_func_2015);
var VIIRS_nighttimeLights_2016 = VIIRS_nighttimeLights_2015.map(VIIRS_nighttimeLights_func_2016);
var VIIRS_nighttimeLights_2017 = VIIRS_nighttimeLights_2016.map(VIIRS_nighttimeLights_func_2017);
var VIIRS_nighttimeLights_2018 = VIIRS_nighttimeLights_2017.map(VIIRS_nighttimeLights_func_2018);
var VIIRS_nighttimeLights_2019 = VIIRS_nighttimeLights_2018.map(VIIRS_nighttimeLights_func_2019);
var VIIRS_nighttimeLights_2020 = VIIRS_nighttimeLights_2019.map(VIIRS_nighttimeLights_func_2020);
var VIIRS_nighttimeLights_2021 = VIIRS_nighttimeLights_2020.map(VIIRS_nighttimeLights_func_2021);
Export.table.toDrive({
collection: VIIRS_nighttimeLights_2021,
description: 'VIIRS_nighttimeLights_2021',
selectors: ['GEFID', 'avg_rad_2014', 'avg_rad_2015', 'avg_rad_2016', 'avg_rad_2017', 'avg_rad_2018',
'avg_rad_2019', 'avg_rad_2020', 'avg_rad_2021']
});