-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
521 lines (485 loc) · 20.1 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Climate Explorer</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.24.2/plotly.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/flatgeobuf-geojson.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-zoom/2.0.1/chartjs-plugin-zoom.min.js"></script>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
font-family: Arial, sans-serif;
background: #FFFFFF;
}
.container {
height: 100%;
display: flex;
flex-direction: column;
}
.tabs {
display: flex;
padding: 20px;
gap: 10px;
background: #FFFFFF;
}
.tab {
flex: 1;
padding: 12px 24px;
cursor: pointer;
background: #e0e0e0;
text-align: center;
border: none;
/* border-radius: 25px; */
font-size: 16px;
transition: all 0.3s ease;
color: #666;
}
.tab:hover {
background: #d0d0d0;
}
.tab.active {
background: #4a90e2;
color: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.content {
flex-grow: 1;
position: relative;
margin: 0 20px 20px 20px;
border-radius: 15px;
overflow: hidden;
border: 1px solid #ddd;
background: white;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.map {
height: 100%;
width: 100%;
}
.sidebar {
display: none;
position: absolute;
right: 20px;
top: 20px;
bottom: 20px;
width: 300px;
background: rgba(255, 255, 255, 0.25); /* Made more transparent */
padding: 20px;
border-radius: 12px;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
z-index: 1000;
overflow-y: auto;
backdrop-filter: blur(5px); /* Added blur effect for better readability */
}
.section-title {
margin: 0px 0px;
}
.sidebar-title {
margin: 0px 0px 10px 0px;
}
/* Make form elements and plot container fully opaque for contrast */
select, .multiselect, .plot-container {
background: white;
}
.sidebar.active {
display: flex;
flex-direction: column;
}
select {
width: 100%;
margin: 10px 0;
padding: 10px;
border-radius: 8px;
border: 1px solid #ddd;
background: white;
font-size: 14px;
}
select:focus {
outline: none;
border-color: #4a90e2;
}
.multiselect {
border: 1px solid #ddd;
padding: 12px;
margin: 10px 0;
max-height: 300px;
overflow-y: auto;
border-radius: 8px;
background: white;
}
.multiselect label {
display: block;
margin: 8px 0;
color: #444;
}
.plot-container {
margin-top: 20px;
flex-grow: 1;
min-height: 300px;
background: white;
border-radius: 8px;
border: 1px solid #ddd;
}
.chart-container {
width: 800px;
height: 400px;
margin: 20px auto;
position: relative;
}
.logo {
position: absolute;
top: 10px;
left: 10px;
width: 50px;
height: 50px;
z-index: 10;
background: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-family: Arial, sans-serif;
color: #333;
border: 2px solid #ddd;
}
.controls {
text-align: center;
margin: 10px;
}
button {
padding: 8px 16px;
margin: 0 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="tabs">
<a href="https://climate.umt.edu" style="display: flex; align-items: center; margin-right: 20px;">
<img src="https://data.climate.umt.edu/website/assets/MCO_logo.png" alt="MCO Logo" style="height: 40px;">
</a>
<button class="tab active" onclick="switchTab(0)">Historical Trends</button>
<button class="tab" onclick="switchTab(1)">Climate Projections</button>
<button class="tab" onclick="switchTab(2)">Report Builder</button>
</div>
<div class="content">
<div id="map" class="map"></div>
<div class="sidebar active">
<h2 class="sidebar-title">Climate and Vegetation Trends</h2>
<h3 class="section-title">Variable Selection</h3>
<select id="historical-variable-selector">
<optgroup label="GridMET Variables">
<option value="erc">Energy Release Component</option>
<option value="etr">Potential ET (Alfalfa)</option>
<option value="pet">Potential ET (Grass)</option>
<option value="pr" selected="selected">Precipitation</option>
<option value="rmax">Maximum Relative Humidity</option>
<option value="rmin">Minimum Relative Humidity</option>
<option value="tmmn">Minumum Temperature</option>
<option value="tmmx">Maximum Temperature</option>
<option value="vpd">Vapor Pressure Deficit</option>
<option value="vs">Wind Speed</option>
</optgroup>
<optgroup label="Satellite Indicators">
<option value="afg">RAP Annual Forb and Grass Cover</option>
<option value="bgr">RAP Bare Ground Cover</option>
<option value="pfg">RAP Perennial Forb and Grass Cover</option>
<option value="shr">RAP Shrub Cover</option>
<option value="tre">RAP Tree Cover</option>
<option value="evi">MOD13 EVI</option>
<option value="ndvi">MOD13 NDVI</option>
<option value="et_m16">MOD16 ET</option>
<option value="pet_m16">MOD16 PET</option>
<option value="gpp">MOD17 GPP</option>
<option value="afgnpp">RAP Forb and Grass NPP</option>
<option value="pfgnpp">RAP Perennial Forb and Grass NPP</option>
<option value="shrnpp">RAP Shrub NPP</option>
<option value="trenpp">RAP Tree NPP</option>
</optgroup>
</select>
<h3 class="section-title">Time Period</h3>
<select id="historical-time-selector">
<option value="annual">Annual</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<div id="plot1" class="plot-container"></div>
</div>
<h3 class="section-title">Region Type</h3>
<select>
<option>Ut enim ad minim veniam</option>
<option>Quis nostrud exercitation</option>
<option>Ullamco laboris nisi ut</option>
</select>
<h3 class="section-title">Data Categories</h3>
<div class="multiselect">
<label><input type="checkbox"> Duis aute irure dolor</label>
<label><input type="checkbox"> In reprehenderit in voluptate</label>
<label><input type="checkbox"> Velit esse cillum dolore</label>
<label><input type="checkbox"> Eu fugiat nulla pariatur</label>
<label><input type="checkbox"> Excepteur sint occaecat</label>
</div>
<div class="chart-container", id="historical_chart_container">
<div class="logo">LOGO</div>
<canvas id="historical_chart"></canvas>
</div>
</div> </div>
<div class="sidebar">
<h2 class="sidebar-title">Economic Indicators</h2>
<h3 class="section-title">Industry Sector</h3>
<select>
<option>Nulla facilisi morbi tempus</option>
<option>Iaculis urna id volutpat</option>
<option>Lacus suspendisse faucibus</option>
</select>
<h3 class="section-title">Metric Type</h3>
<select>
<option>Interdum consectetur libero</option>
<option>Id faucibus nisl tincidunt</option>
<option>Eget nullam non nisi est</option>
</select>
<h3 class="section-title">Economic Factors</h3>
<div class="multiselect">
<label><input type="checkbox"> Sit amet tellus cras</label>
<label><input type="checkbox"> Adipiscing commodo elit at</label>
<label><input type="checkbox"> Imperdiet dui accumsan sit</label>
<label><input type="checkbox"> Amet volutpat consequat mauris</label>
<label><input type="checkbox"> Nunc consequat interdum varius</label>
</div>
<div class="chart-container", id="future_chart_container">
<div class="logo">LOGO</div>
<canvas id="future_chart"></canvas>
</div>
</div>
<div class="sidebar">
<h2 class="sidebar-title">Environmental Data</h2>
<h3 class="section-title">Environmental Category</h3>
<select>
<option>Dignissim convallis aenean et</option>
<option>Tortor at risus viverra</option>
<option>Adipiscing at in tellus</option>
</select>
<h3 class="section-title">Data Source</h3>
<select>
<option>Integer eget aliquet nibh</option>
<option>Praesent elementum facilisis</option>
<option>Leo vel fringilla est</option>
</select>
<h3 class="section-title">Impact Metrics</h3>
<div class="multiselect">
<label><input type="checkbox"> Ullamcorper sit amet risus</label>
<label><input type="checkbox"> Nullam ac tortor vitae</label>
<label><input type="checkbox"> Purus gravida quis blandit</label>
<label><input type="checkbox"> Turpis cursus in hac</label>
<label><input type="checkbox"> Habitasse platea dictumst</label>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/papaparse.min.js"></script>
<script>
function switchTab(index) {
// Update tab styles
document.querySelectorAll('.tab').forEach((tab, i) => {
tab.classList.toggle('active', i === index);
});
// Update sidebar visibility
document.querySelectorAll('.sidebar').forEach((sidebar, i) => {
sidebar.classList.toggle('active', i === index);
});
// Trigger resize for plot
window.dispatchEvent(new Event('resize'));
}
// Add event listener for variable selector changes
document.getElementById('historical-variable-selector').addEventListener('change', function(e) {
const timeSelector = document.getElementById('historical-time-selector');
const selectedVariable = e.target.value;
// Hide monthly options for satellite variables
const satelliteVars = ['afg', 'bgr', 'pfg', 'shr', 'tre', 'evi', 'ndvi', 'et_m16', 'pet_m16', 'gpp', 'afgnpp', 'pfgnpp', 'shrnpp', 'trenpp'];
Array.from(timeSelector.options).forEach(option => {
if (option.value !== 'annual') {
option.style.display = satelliteVars.includes(selectedVariable) ? 'none' : '';
}
});
// Reset to annual if satellite variable selected and monthly was previously selected
if (satelliteVars.includes(selectedVariable) && timeSelector.value !== 'annual') {
timeSelector.value = 'annual';
}
});
async function get_df(f) {
try {
const response = await fetch(f);
const csv = await response.text();
const results = Papa.parse(csv, {
header: true,
dynamicTyping: true
});
parsed_data = results.data;
} catch (error) {
parsed_data = null
console.error('Error loading CSV:', error);
}
return parsed_data
}
</script>
</script>
<script>
// Montana coordinates
const MONTANA_CENTER = [46.8797, -108.8];
const ZOOM_LEVEL = 6.5;
// Initialize single map instance
const map = L.map('map').setView(MONTANA_CENTER, ZOOM_LEVEL);
// Add base tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Store layers for the control panel
var overlayMaps = {};
// Create the layer control immediately with baseLayers (first argument) instead of overlays
const baseMaps = L.control.layers({}, null, {
collapsed: false,
position: 'topleft'
}).addTo(map);
/**
* Loads a FlatGeobuf layer and adds it to the layer control
* @param {string} url - URL of the FlatGeobuf file
* @param {string} layerId - Unique identifier for the layer
* @param {string} layerName - Display name for the layer in the control panel
* @param {Object} style - Leaflet style object for the features
* @returns {Promise<void>}
*/
async function loadFlatGeobufLayer(url, layerId, layerName, add_to_group = true, style = {
fillColor: "rgba(0, 0, 0, 0)",
fillOpacity: 0.9,
color: "black",
weight: 1
}) {
try {
// Create a feature group for the layer
const layerGroup = L.featureGroup();
const response = await fetch(url);
for await (const feature of flatgeobuf.deserialize(response.body)) {
var feat = L.geoJSON(feature, {
style: () => style,
onEachFeature: (feature, layer) => {
if (feature.properties && add_to_group) {
layer.bindTooltip(
feature.properties.name
);
}
}
})
if (add_to_group) {
feat.addTo(layerGroup);
} else {
feat.addTo(map);
}
}
if (add_to_group) {
// Add the layer to the overlay maps object
overlayMaps[layerId] = layerGroup;
baseMaps.addBaseLayer(layerGroup, layerName);
}
if (Object.keys(overlayMaps).length === 1) {
layerGroup.addTo(map);
}
} catch (error) {
console.error(`Error loading FlatGeobuf layer ${layerId}:`, error);
}
}
async function main() {
await loadFlatGeobufLayer(
"https://data.climate.umt.edu/mt-normals/fgb/mt.fgb",
"",
"",
false,
style = {
fillColor: "rgba(0, 0, 0, 0)",
fillOpacity: 0.9,
color: "black",
weight: 3
}
);
await loadFlatGeobufLayer(
"https://data.climate.umt.edu/mt-normals/fgb/explorer/counties.fgb",
"counties",
"Counties"
);
await loadFlatGeobufLayer(
"https://data.climate.umt.edu/mt-normals/fgb/explorer/blm.fgb",
"blm",
"BLM Districts"
);
await loadFlatGeobufLayer(
"https://data.climate.umt.edu/mt-normals/fgb/explorer/hucs.fgb",
"hucs",
"HUCs"
);
await loadFlatGeobufLayer(
"https://data.climate.umt.edu/mt-normals/fgb/explorer/tribes.fgb",
"tribes",
"Tribal Lands"
);
f = 'https://data.climate.umt.edu/mt-normals/csvs/historical/rmax_huc_17010105.csv'
var dat = await get_df(f);
console.log(dat);
Object.entries(overlayMaps).forEach(([key, value]) => {
value.on("click", event => {
const parts = event.layer.feature.properties.id.split("_");
console.log(parts);
})
});
function createPlot(elementId) {
const data = [{
x: Array.from({length: 10}, (_, i) => i),
y: Array.from({length: 10}, () => Math.random() * 10),
type: 'scatter',
mode: 'lines+markers',
line: {color: '#4a90e2'}
}];
const layout = {
margin: { t: 20, r: 20, l: 40, b: 40 },
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
xaxis: {
title: 'Time',
gridcolor: '#eee'
},
yaxis: {
title: 'Value',
gridcolor: '#eee'
}
};
Plotly.newPlot(elementId, data, layout, {
responsive: true,
displayModeBar: false
});
}
// Initialize plots
createPlot('plot1');
createPlot('plot2');
}
main();
</script>
</body>
</html>