-
Notifications
You must be signed in to change notification settings - Fork 27
/
ycbcr.html
49 lines (47 loc) · 1.81 KB
/
ycbcr.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<style>
#map {
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/browse/[email protected]/dist/fetch.umd.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/georaster"></script>
<script src="https://unpkg.com/georaster-layer-for-leaflet"></script>
<script>
// initalize leaflet map
var map = L.map("map").setView([-33.9872346, 115.0242196], 14);
// add OpenStreetMap basemap
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var url_to_geotiff_file = "https://maxar-ard-samples.s3.amazonaws.com/v3/australia_vineyards/50/213133231011/2019-10-07/10500100191CD200-visual.tif";
parseGeoraster(url_to_geotiff_file).then(function (georaster) {
console.log("georaster:", georaster);
const layer = new GeoRasterLayer({
attribution: "GeoTIFF from Maxar",
debugLevel: 0,
georaster,
pixelValuesToColorFn: values => {
const r = Math.round(values[0] + 1.40200 * (values[2] - 0x80));
const g = Math.round(values[0] - 0.34414 * (values[1] - 0x80) - 0.71414 * (values[2] - 0x80));
const b = Math.round(values[0] + 1.77200 * (values[1] - 0x80));
return `rgb(${r},${g},${b})`;
}
});
layer.addTo(map);
});
</script>
</body>
</html>