forked from UN-SPIDER/burn-severity-mapping-EO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
141 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"NBR": { | ||
"metric_name": "Normalized Burn Ratio", | ||
"formula": "NBR = \\\\frac{NIR - SWIR}{NIR + SWIR}" | ||
}, | ||
"dNBR": { | ||
"metric_name": "Difference in Normalized Burn Ratio", | ||
"formula": "dNBR = NBR_{prefire} - NBR_{postfire}" | ||
}, | ||
"RdNBR": { | ||
"metric_name": "Relative Difference in Normalized Burn Ratio", | ||
"formula": "RdNBR = \\\\frac{dNBR}{|(NBR_{prefire})^{0.5}|}" | ||
}, | ||
"RBR": { | ||
"metric_name": "Relativized Burn Ratio", | ||
"formula": "RBR = \\\\frac{dNBR}{NBR_{prefire} +1.001}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Leaflet Map</title> | ||
|
||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
<!-- Include Leaflet CSS --> | ||
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> | ||
|
||
<!-- Include Leaflet JS --> | ||
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> | ||
|
||
<!-- Include MathJax --> | ||
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> | ||
<script id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> | ||
|
||
<style> | ||
#mapid { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="mapid"></div> | ||
<div style="position: absolute; top: 10px; right: 10px; z-index: 1000; padding: 10px; border-radius: 10px; background-color: #f0f0f0;"> | ||
<label for="opacity-slider">Burn Severity Layer Opacity</label> | ||
<input type="range" min="0" max="1" step="0.1" value=".7" id="opacity-slider"> | ||
</div> | ||
<script> | ||
var map = L.map('mapid'); | ||
|
||
// Data from Jinja2 | ||
console.log("burn_metric - {{ burn_metric }}") | ||
var burn_metric = "{{ burn_metric }}"; | ||
|
||
console.log("fire metadata") | ||
var fireMetadata = JSON.parse({{fire_metadata_json | tojson | safe}}); | ||
console.log(fireMetadata); | ||
|
||
var fire_bounds = [[fireMetadata.bounds[1], fireMetadata.bounds[0]], [fireMetadata.bounds[3], fireMetadata.bounds[2]]] | ||
console.log("fire bounds - ", fire_bounds) | ||
|
||
// Content for the webpage, defined as JSON | ||
var burnMetricText = JSON.parse('{{ burn_metric_text | tojson | safe }}'); | ||
|
||
// Add base map | ||
L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { | ||
attribution: '© OpenStreetMap contributors' | ||
}).addTo(map); | ||
|
||
// Add COG tile layer, with opacity slider | ||
var cogTileLayer = L.tileLayer('{{ cog_tileserver_url_prefix | safe }}{"thresholds":{"-0.9998":0, "0.045":175,"0.222":100,"0.8":25}}', { | ||
maxZoom: 20, | ||
setOpacity: 0.7, | ||
}).addTo(map); | ||
var slider = document.getElementById('opacity-slider'); | ||
slider.addEventListener('input', function(e) { | ||
cogTileLayer.setOpacity(e.target.value); | ||
}); | ||
|
||
// Add tooltip for burn metrics, in bottom left | ||
// Get the container | ||
var container = document.createElement('div'); | ||
container.style.position = 'absolute'; | ||
container.style.bottom = '10px'; | ||
container.style.left = '10px'; | ||
container.style.zIndex = '1000'; | ||
container.style.padding = '10px'; | ||
container.style.borderRadius = '10px'; | ||
container.style.backgroundColor = '#f0f0f0'; | ||
|
||
// Iterate over each metric | ||
for (var key in burnMetricText) { | ||
// Create a div for the metric | ||
var div = document.createElement('div'); | ||
|
||
// Add the metric name and formula | ||
div.innerHTML = '<strong>' + burnMetricText[key].metric_name + '</strong><br> <span class="math">\\(' + burnMetricText[key].formula + '\\)</span>'; | ||
|
||
// Add padding between divs | ||
div.style.padding = '10px'; | ||
|
||
// Highlight the current metric | ||
if (key.toLowerCase() === burn_metric.toLowerCase()) { | ||
div.style.backgroundColor = '#ffe875'; | ||
} | ||
|
||
// Append the div to the container | ||
container.appendChild(div); | ||
|
||
// Ask MathJax to typeset the new div | ||
MathJax.typeset([div]); | ||
} | ||
|
||
// Append the container to the body | ||
document.body.appendChild(container); | ||
|
||
// Center map on fire, based on `bounds` metadata | ||
map.fitBounds(fire_bounds); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |