-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_layer_func
200 lines (157 loc) · 7.1 KB
/
get_layer_func
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
// released under Open Source GPL License Copyright © 2023 Ka Hei Chow
// ######################################### //
// ###### Functions for Map ###### //
// ###### Comparison Tool ###### //
// ######################################### //
/**
* This script contains functions to get different geospatial layers
* to be fired once data layer is selected by users
*/
// get Global Extreme Heat Hazard
// https://gee-community-catalog.org/projects/heat-hazard/
// 100 year return period
exports.get_heat_100y = function get_heat_100y(aoi) {
var global_extreme_heat_hazard = ee.ImageCollection("projects/sat-io/open-datasets/WORLD-BANK/global-ext-heat-hazard");
var heat_100y = global_extreme_heat_hazard.filter(ee.Filter.eq('id_no', "intensity_returnperiod100y")).first();
return heat_100y.clip(aoi);
};
// 20 year return period
exports.get_heat_20y = function get_heat_20y(aoi) {
var global_extreme_heat_hazard = ee.ImageCollection("projects/sat-io/open-datasets/WORLD-BANK/global-ext-heat-hazard");
var heat_20y = global_extreme_heat_hazard.filter(ee.Filter.eq('id_no', "intensity_returnperiod20y")).first();
return heat_20y.clip(aoi);
};
// 5 year return period
exports.get_heat_5y = function get_heat_5y(aoi) {
var global_extreme_heat_hazard = ee.ImageCollection("projects/sat-io/open-datasets/WORLD-BANK/global-ext-heat-hazard");
var heat_5y = global_extreme_heat_hazard.filter(ee.Filter.eq('id_no', "intensity_returnperiod5y")).first();
return heat_5y.clip(aoi);
};
// get Landscan latest population layer (2021)
// https://gee-community-catalog.org/projects/landscan/?h=landscan
exports.get_landscan_pop = function get_landscan_pop(aoi) {
var landscan_global = ee.ImageCollection("projects/sat-io/open-datasets/ORNL/LANDSCAN_GLOBAL");
var landscan_2021 = landscan_global.sort('system:time_start',false).first();
return landscan_2021.clip(aoi);
};
// get Palmer Drought Severity Index (historical average between 2010 and 2023)
// https://developers.google.com/earth-engine/datasets/catalog/IDAHO_EPSCOR_TERRACLIMATE
exports.get_pdsi = function get_pdsi(aoi) {
// return the list of coordinates
var centroid = aoi.first().geometry().centroid();
var listCoords = ee.Array.cat(centroid.coordinates(), 0);
var yCoords = ee.List(listCoords).getInfo()[1];
var south = ee.Number(yCoords).lt(0);
var shift = south.multiply(6).getInfo();
var summerFilter = ee.Filter.calendarRange(5+shift, 9+shift, "month");
var yearFilter = ee.Filter.date(ee.Date("2010-01-01"),ee.Date("2023-01-01"));
var dataset = ee.ImageCollection('IDAHO_EPSCOR/TERRACLIMATE')
.filter(yearFilter).filter(summerFilter);
var drought_index = dataset.select('pdsi').median().multiply(0.01).clip(aoi);
return drought_index;
};
// get MODIS temperature difference between daytime and nighttime
// https://developers.google.com/earth-engine/datasets/catalog/OpenLandMap_CLM_CLM_LST_MOD11A2-DAYNIGHT_M_v01
exports.get_temp_diff = function get_temp_diff(aoi) {
var temp_diff = ee.Image("OpenLandMap/CLM/CLM_LST_MOD11A2-DAYNIGHT_M/v01")
.reduce('mean')
.multiply(0.02);
return temp_diff.clip(aoi);
};
// get GHSL urbanization degree
// https://developers.google.com/earth-engine/datasets/catalog/JRC_GHSL_P2016_SMOD_POP_GLOBE_V1
exports.get_urban_degree = function get_urban_degree(aoi) {
var dataset = ee.ImageCollection('JRC/GHSL/P2016/SMOD_POP_GLOBE_V1')
.filter(ee.Filter.date('2015-01-01', '2015-12-31'));
var degreeOfUrbanization = dataset.select('smod_code').sum().clip(aoi);
return degreeOfUrbanization;
};
// get urban heat island index daytime
// https://developers.google.com/earth-engine/datasets/catalog/YALE_YCEO_UHI_Summer_UHI_yearly_pixel_v4
exports.get_uhi_day = function get_uhi_day(aoi) {
var uhi = ee.ImageCollection('YALE/YCEO/UHI/Summer_UHI_yearly_pixel/v4')
.select('Daytime')
.filter(ee.Filter.inList('system:index', ["2018"]))
.first();
return uhi.clip(aoi);
};
// get urban heat island index nighttime
// https://developers.google.com/earth-engine/datasets/catalog/YALE_YCEO_UHI_Summer_UHI_yearly_pixel_v4
exports.get_uhi_night = function get_uhi_night(aoi) {
var uhi = ee.ImageCollection('YALE/YCEO/UHI/Summer_UHI_yearly_pixel/v4')
.select('Nighttime')
.filter(ee.Filter.inList('system:index', ["2018"]))
.first();
return uhi.clip(aoi);
};
// get density of forest class within 5 km radius in Land Cover
// https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v200
exports.get_forest_density = function get_forest_density(aoi) {
var bbox = aoi.geometry();
// get urban areas
var lulc = ee.ImageCollection('ESA/WorldCover/v200')
.first()
.clip(bbox);
var urban_mask = lulc.eq(10);
// calculate urban density
var reduceNeighborhood = urban_mask.reduceNeighborhood(
ee.Reducer.mean(),
ee.Kernel.circle(5000, 'meters')
).multiply(100).toByte();
return reduceNeighborhood;
};
// get density of cropland class within 5 km radius in Land Cover
// https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v200
exports.get_cropland_density = function get_cropland_density(aoi) {
var bbox = aoi.geometry();
// get urban areas
var lulc = ee.ImageCollection('ESA/WorldCover/v200')
.first()
.clip(bbox);
var urban_mask = lulc.eq(40);
// calculate urban density
var reduceNeighborhood = urban_mask.reduceNeighborhood(
ee.Reducer.mean(),
ee.Kernel.circle(5000, 'meters')
).multiply(100).toByte();
return reduceNeighborhood;
};
// get density of urban class within 5 km radius in Land Cover
// https://developers.google.com/earth-engine/datasets/catalog/ESA_WorldCover_v200
exports.get_urban_density = function get_urban_density(aoi) {
var bbox = aoi.geometry();
// get urban areas
var lulc = ee.ImageCollection('ESA/WorldCover/v200')
.first()
.clip(bbox);
var urban_mask = lulc.eq(50);
// calculate urban density
var reduceNeighborhood = urban_mask.reduceNeighborhood(
ee.Reducer.mean(),
ee.Kernel.circle(5000, 'meters')
).multiply(100).toByte();
return reduceNeighborhood;
};
// get critical infrastructure spatial index
// https://www.nature.com/articles/s41597-022-01218-4
exports.get_cisi = function get_cisi(aoi) {
return ee.Image("projects/sat-io/open-datasets/CISI/global_CISI").clip(aoi);
};
// get relative wealth index
// https://dataforgood.facebook.com/dfg/tools/relative-wealth-index
exports.get_rwi = function get_rwi(aoi) {
// get RWI data layer from community project (Layer 2)
var rwi_ds = ee.FeatureCollection("projects/sat-io/open-datasets/facebook/relative_wealth_index");
// buffer point grid to fill gaps
var aoi_rwi = rwi_ds.filterBounds(aoi).map(
function(point) {
return point.buffer(2000);
});
// convert point grid to raster image
var rwi = aoi_rwi.filter(ee.Filter.notNull(['rwi']))
.reduceToImage({
properties: ['rwi'],
reducer: ee.Reducer.mean(),
});
return rwi;
};