-
Notifications
You must be signed in to change notification settings - Fork 5
/
landscan_population
175 lines (149 loc) · 6.19 KB
/
landscan_population
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
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var landscan_global = ee.ImageCollection("projects/sat-io/open-datasets/ORNL/LANDSCAN_GLOBAL");
/***** End of imports. If edited, may not auto-convert in the playground. *****/
//▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▄▀
//▄▀▄▀▄ ▄▀▄▀▄▀▄
//▄▀▄▀▄ COPY THIS URL LINK TO PLAY AROUND WITH THE CODE ▄▀▄▀▄▀▄
//▄▀▄▀▄ ▄▀▄▀▄▀▄
//▄▀▄▀▄ https://code.earthengine.google.com/30e1c1f66bf7938a8cbd200bb10dca56 ▄▀▄▀▄▀▄
//▄▀▄▀▄ ▄▀▄▀▄▀▄
//▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
// ######################################### //
// ###### Landscan Population ###### //
// ######################################### //
/**
* This is an example script for visualizing dataset from awesome gee commmunity
* on Landscan population count. It is a gridded raster data layer based on
* rapid, large-scale detection of human settlements from high resolution imagery.
* The data layer has high scientific confidence compared to other available datasets.
*
* This script produce visualization for an area of interest (i.e. Pakistan in this example).
*
* Dataset Source:
* Sims, K., Reith, A., Bright, E., McKee, J., & Rose, A. (2022). LandScan Global 2021 [Data set]. Oak Ridge National Laboratory.
* https://doi.org/10.48690/1527702
*
* Project Details:
* https://gee-community-catalog.org/projects/landscan/
*
*/
// import modules
var palettes = require('users/gena/packages:palettes');
var analysis = require('users/pinkychow1010/WB_IntraUrban:analysis_utils');
// population legend layout
var popcount_intervals =
'<RasterSymbolizer>' +
' <ColorMap type="intervals" extended="false" >' +
'<ColorMapEntry color="#CCCCCC" quantity="0" label="No Data"/>' +
'<ColorMapEntry color="#FFFFBE" quantity="5" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#FEFF73" quantity="25" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#FEFF2C" quantity="50" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#FFAA27" quantity="100" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#FF6625" quantity="500" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#FF0023" quantity="2500" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#CC001A" quantity="5000" label="Population Count (Estimate)"/>' +
'<ColorMapEntry color="#730009" quantity="185000" label="Population Count (Estimate)"/>' +
'</ColorMap>' +
'</RasterSymbolizer>';
// Define a dictionary which will be used to make legend and
// visualize image on map
var dict = {
"names": [
"0",
"1-5",
"6-25",
"26-50",
"51-100",
"101-500",
"501-2500",
"2501-5000",
"5001-185000"
],
"colors": [
"#CCCCCC",
"#FFFFBE",
"#FEFF73",
"#FEFF2C",
"#FFAA27",
"#FF6625",
"#FF0023",
"#CC001A",
"#730009"
]};
// create a panel to hold the legend widget
var legend = ui.Panel({
style: {
position: 'bottom-left',
padding: '8px 15px'
}
});
// call function for legend
addCategoricalLegend(legend, dict, 'Population Count(estimate)');
// get landscan 2000 and 2021
var landscan_2000 = landscan_global.sort('system:time_start').first().sldStyle(popcount_intervals);
var landscan_2021 = landscan_global.sort('system:time_start',false).first().sldStyle(popcount_intervals);
// get area of interest: Pakistan
var ADM2 = ee.FeatureCollection('projects/earthengine-legacy/assets/projects/sat-io/open-datasets/geoboundaries/CGAZ_ADM2');
var pakistan = ADM2.filter(ee.Filter.eq('shapeGroup', 'PAK'));
Map.centerObject(pakistan, 6);
// display raster layers
Map.addLayer(landscan_2000.clip(pakistan), {}, 'Pakistan Population Count 2000');
Map.addLayer(landscan_2021.clip(pakistan), {}, 'Pakistan Population Count 2021');
// customized basemap to enhance visuals
var basemap = require('users/pinkychow1010/WB_IntraUrban:basemap_resources');
basemap.addCustomBasemap('simpleLight');
// add title label
Map.add(ui.Label('Landscan Population in Pakistan (2021)',
{
position: 'top-center',
fontSize: '30px',
backgroundColor: '#0047AB',
fontWeight: '500',
color: 'white'
}
));
// Function to generate the legend
function addCategoricalLegend(panel, dict, title) {
// Create and add the legend title.
var legendTitle = ui.Label({
value: title,
style: {
fontWeight: 'bold',
fontSize: '18px',
margin: '0 0 4px 0',
padding: '0'
}
});
panel.add(legendTitle);
var loading = ui.Label('Loading legend...', {margin: '2px 0 4px 0'});
panel.add(loading);
// Creates and styles 1 row of the legend.
var makeRow = function(color, name) {
// Create the label that is actually the colored box.
var colorBox = ui.Label({
style: {
backgroundColor: color,
// Use padding to give the box height and width.
padding: '8px',
margin: '0 0 4px 0'
}
});
// Create the label filled with the description text.
var description = ui.Label({
value: name,
style: {margin: '0 0 4px 6px'}
});
return ui.Panel({
widgets: [colorBox, description],
layout: ui.Panel.Layout.Flow('horizontal')
});
};
// Get the list of palette colors and class names from the image.
var palette = dict['colors'];
var names = dict['names'];
loading.style().set('shown', false);
for (var i = 0; i < names.length; i++) {
panel.add(makeRow(palette[i], names[i]));
}
Map.add(panel);
}