-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
470 lines (415 loc) · 18.9 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>geotiff.js and plotty.js</title>
<meta name="description" content="Visualizing Scientific Raster Data in the Browser">
<meta name="author" content="Fabian Schindler">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="lib/reveal.js/css/reveal.css">
<link rel="stylesheet" href="lib/reveal.js/css/theme/blood.css" id="theme">
<link rel="stylesheet" href="lib/openlayers/dist/ol.css" id="theme">
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.min.css">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/reveal.js/lib/css/zenburn.css">
<script src="lib/jquery/dist/jquery.min.js"></script>
</head>
<body>
<script src="lib/reveal.js/lib/js/head.min.js"></script>
<script src="lib/reveal.js/js/reveal.js"></script>
<script src="lib/geotiff/dist/geotiff.js"></script>
<script src="lib/plotty/dist/plotty.min.js"></script>
<script src="lib/openlayers/dist/ol.js"></script>
<div class="reveal">
<div class="slides">
<section data-background="data/background.png">
<h1>geotiff.js and plotty.js</h1>
<h3>Visualizing Scientific Raster Data in the Browser</h3>
</section>
<section>
<h2>About us</h2>
<div style="float:left; width: 45%">
<p>Daniel Santillan</p>
<img src="https://avatars0.githubusercontent.com/u/4036819?v=3&s=200">
<p><a href="https://github.com/santilland"><i class="fa fa-github-square" aria-hidden="true"></i> santilland</a></p>
<p><a href="https://twitter.com/daniel_san123"><i class="fa fa-twitter-square" aria-hidden="true"></i> daniel_san123</a></p>
</div>
<div style="float:right; width: 45%">
<p>Fabian Schindler</p>
<img src="https://avatars3.githubusercontent.com/u/1109799?v=3&s=200">
<p><a href="https://github.com/constantinius"><i class="fa fa-github-square" aria-hidden="true"></i> constantinius</a></p>
<p><a href="https://twitter.com/__fschindler__"><i class="fa fa-twitter-square" aria-hidden="true"></i> __fschindler__</a></p>
</div>
<p><a href="http://eox.at"><img style="background-color: white; border-color:white;" src="data/eox.svg" alt="EOX IT Services"></a></p>
</section>
<section>
<section>
<h2>Premise</h2>
<p>Scientific raster data exploration either desktop based or very restricted</p>
<p>Prerendered</p>
<p>Or Server-Side On-Demand styling</p>
</section>
<section>
<h2>Goals</h2>
<p>Fully interactive raster visualization</p>
<p>HTML / JavaScript only</p>
<p>Integration with Web-Mapping Frameworks</p>
</section>
<section>
<h2>HTML 5</h2>
<p>Canvas API</p>
<p>Web GL</p>
<p>Typed Arrays</p>
</section>
<section>
<h2>Required steps</h2>
<p>Transfer Raster Data</p>
<p>Raster Rendering</p>
</section>
</section>
<section>
<section>
<h2>Transfer Format - GeoTIFF</h2>
<p>Good software support</p>
<p>Flexible (<b>T</b>housand <b>I</b>ncompatible <b>F</b>ile <b>F</b>ormats)</p>
<p>Extensible</p>
<p>Geographic Metadata</p>
</section>
<section>
<h2>GeoTIFF.js - technologies</h2>
<p>Pure JavaScript (ECMA 2015) implementation</p>
<p>Typed Arrays + DataViews</p>
</section>
<section>
<h2>GeoTIFF.js - capabilities</h2>
<ul>
<li>Full implementation of baseline TIFF</li>
<li>Tiled/Stripped</li>
<li>Band/Pixel interleave</li>
<li>various datatypes</li>
<li>No compression, Packbits (Deflate and LZW to follow)</li>
<li>Parsing of Geo-Metadata</li>
</ul>
</section>
<section>
<h2>GeoTIFF.js - Demo</h2>
<button id="test-geotiff">Test GeoTIFF.js</button>
<div id="test-geotiff-status">Click the button above...</div>
<canvas width="541" height="449" id="test-geotiff-canvas"/>
<script>
$('#test-geotiff').click(() => {
$('#test-geotiff-status').text('Loading ...')
fetch('data/rgba.tiff')
.then(response => response.arrayBuffer())
.then(buffer => {
var tiff = GeoTIFF.parse(buffer);
var image = tiff.getImage();
$('#test-geotiff-status').text(
'Parsed GeoTIFF. Width: ' + image.getWidth() +
', Height: ' + image.getHeight() +
', Samples: ' + image.getSamplesPerPixel()
);
var canvas = document.getElementById('test-geotiff-canvas');
var ctx = canvas.getContext('2d');
var imageData = ctx.createImageData(image.getWidth(), image.getHeight());
var pixels = image.readRasters({ interleave: true })
for (var i = 0; i < pixels.length; ++i) {
imageData.data[i] = pixels[i];
}
ctx.putImageData(imageData, 0, 0);
});
});
</script>
</section>
<section>
<h2>GeoTIFF.js - Demo - Under the Hood</h2>
<pre><code class="hljs" data-trim>
fetch('data/rgba.tiff')
.then(function(response) { return response.arrayBuffer(); })
.then(function(buffer) {
var tiff = GeoTIFF.parse(buffer);
var image = tiff.getImage();
var ctx = document.getElementById('canvas').getContext('2d');
var imageData = ctx.createImageData(
image.getWidth(), image.getHeight());
var pixels = image.readRasters({ interleave: true })
for (var i = 0; i < pixels.length; ++i) {
imageData.data[i] = pixels[i];
}
ctx.putImageData(imageData, 0, 0);
});
</code></pre>
</section>
</section>
<section>
<section>
<h2>What about non-RGB(A) data?</h2>
<p class="fragment">Enter plotty...</p>
</section>
<section>
<h2>plotty.js - capabilities</h2>
<p>Small JavaScript library to render rasters</p>
<p>Colorscales</p>
<p>WebGL / "Software" renderer</p>
</section>
<section>
<h2>plotty.js - Demo</h2>
<button id="test-plotty">Test plotty.js</button>
<p>
<canvas width="300" height="300" id="test-plotty-canvas"/>
</p>
<script>
$('#test-plotty').click(() => {
var width = 300;
var height = 300;
var exampledata = new Float32Array(height * width);
var xoff = width / 3;
var yoff = height / 3;
for (y = 0; y <= height; y++) {
for (x = 0; x <= width; x++) {
// calculate sine based on distance
x2 = x - xoff;
y2 = y - yoff;
d = Math.sqrt(x2*x2 + y2*y2);
t = Math.sin(d/6.0);
// save sine
exampledata[(y*width)+x] = t;
}
}
plot = new plotty.plot({
canvas: document.getElementById("test-plotty-canvas"),
data: exampledata, width: width, height: height,
domain: [-1, 1], colorScale: 'viridis'
});
plot.render();
});
</script>
</section>
<section>
<h2>plotty.js - Demo - Under the Hood</h2>
<pre><code class="hljs" data-trim>
var width = 100, height = 100, xoff = width / 3, yoff = height / 3;
var data = new Float32Array(height * width);
for (y = 0; y <= height; y++) {
for (x = 0; x <= width; x++) {
x2 = x - xoff; y2 = y - yoff;
t = Math.sin(Math.sqrt(x2*x2 + y2*y2)/6.0);
data[(y*width)+x] = t;
}
}
plot = new plotty.plot({
canvas: document.getElementById('canvas'),
data: data, width: width, height: height,
domain: [-1, 1], colorScale: 'viridis'
});
plot.render();
</code></pre>
</section>
</section>
<section>
<h2>Putting it together</h2>
<canvas id="ex1_canvas" style="height: 300px; width: 300px"></canvas>
<span style="width:100%; margin-bottom: 2em">
<select style="width:100%" id="ex1_colorscaleselect"></select>
</span>
<span style="display: table;width:100%">
<label style="width: 3em">Min:</label>
<span style="display: table-cell;width: auto">
<input id="ex1_min" type="range" min="0" max="5000" value="0" style="width:100%"/>
</span>
<label for="ex1_min" id="ex1_min_label" style="display: table-cell;width:3em;text-align:right">0</label>
</span>
<span style="display: table;width:100%">
<label style="width: 3em">Max: </label>
<span style="display: table-cell;width: auto">
<input id="ex1_max" type="range" min="0" max="5000" value="5000" style="width:100%"/>
</span>
<label for="ex1_max" id="ex1_max_label" style="display: table-cell;width:3em;text-align:right">5000</label>
</span>
<span style="display: table;width:100%">
<label style="width: 3em">Clamp Low: </label>
<span style="display: table-cell;width: auto">
<input type="checkbox" id="ex1_clamp_low" checked/>
</span>
</span>
<span style="display: table;width:100%">
<label style="width: 3em">Clamp High: </label>
<span style="display: table-cell;width: auto">
<input type="checkbox" id="ex1_clamp_high" checked/>
</span>
</span>
<script>
fetch('data/ASA_WSM_1PNDPA20050331_075939_000000552036_00035_16121_0775.tiff')
.then(response => response.arrayBuffer())
.then(buffer => {
var parser = GeoTIFF.parse(buffer);
var image = parser.getImage();
var plot;
var colorscaleSelect = document.getElementById("ex1_colorscaleselect");
for(var cm in plotty.colorscales){
var option = document.createElement("option");
option.text = cm;
option.value = cm;
if (cm == "jet")
option.selected = true;
colorscaleSelect.add(option);
}
var inputMin = document.getElementById("ex1_min");
var inputMax = document.getElementById("ex1_max");
var clampLowBox = document.getElementById("ex1_clamp_low");
var clampHighBox = document.getElementById("ex1_clamp_high");
colorscaleSelect.onchange = function() {
plot.setColorScale(this.value);
plot.render();
}
inputMax.oninput = inputMin.oninput = function() {
plot.setDomain([parseInt(inputMin.value), parseInt(inputMax.value)]);
document.getElementById("ex1_min_label").innerHTML = inputMin.value;
document.getElementById("ex1_max_label").innerHTML = inputMax.value;
plot.render()
};
clampLowBox.onchange = clampHighBox.onchange = function() {
plot.setClamp(clampLowBox.checked, clampHighBox.checked);
plot.render();
};
image.readRasters({window: [0, 0, image.getWidth(), image.getHeight()], samples: [0]}, function(rasters) {
var canvas = document.getElementById("ex1_canvas");
plot = new plotty.plot({
canvas: canvas,
data: rasters[0],
width: image.getWidth(),
height: image.getHeight(),
domain: [inputMin.value, inputMax.value],
colorScale: colorscaleSelect.value
});
plot.setClamp(clampLowBox.checked, clampHighBox.checked);
plot.render();
});
})
</script>
</section>
<section id="slide-map-example">
<p><div id="map-loading">Loading map...</div><div id="ex2_map" width="700" height="300" style=""></div></p>
<script>
var map = null;
Reveal.addEventListener('slidechanged', function(event) {
if (event.currentSlide === document.getElementById('slide-map-example') && !map) {
fetch('https://data.eox.at/eudem_ows?service=wcs&version=2.0.1&request=getcoverage&coverageid=EU-DEM&format=image/tiff&SUBSET=long,http://www.opengis.net/def/crs/EPSG/0/4326(15.05,15.40)&SUBSET=lat,http://www.opengis.net/def/crs/EPSG/0/4326(47.75,47.95)&GEOTIFF:COMPRESSION=NONE')
.then(request => request.arrayBuffer())
.then(buffer => {
$('#map-loading').remove();
var parser = GeoTIFF.parse(buffer);
var image = parser.getImage();
var plot;
image.readRasters({window: [0, 0, image.getWidth(), image.getHeight()], samples: [0]}, function(rasters) {
var canvas = document.createElement("canvas");
plot = new plotty.plot({
canvas: canvas, data: rasters[0],
width: image.getWidth(), height: image.getHeight(),
domain: [600, 1300], colorScale: "viridis"
});
plot.setClamp(false);
plot.render();
var projection = ol.proj.get('EPSG:4326');
var size = ol.extent.getWidth(projection.getExtent()) / 256;
var resolutions = new Array(18);
var matrixIds = new Array(18);
for (var z = 0; z < 18; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
resolutions[z] = size / Math.pow(2, z+1);
matrixIds[z] = z;
}
var attribution = new ol.control.Attribution({collapsible: false});
map = new ol.Map({
target: document.getElementById("ex2_map"),
controls: ol.control.defaults({attribution: false}).extend([attribution]),
layers: [
new ol.layer.Tile({
source: new ol.source.WMTS({
urls: [
'//a.tiles.maps.eox.at/wmts/',
'//b.tiles.maps.eox.at/wmts/',
'//c.tiles.maps.eox.at/wmts/',
'//d.tiles.maps.eox.at/wmts/',
'//e.tiles.maps.eox.at/wmts/',
'//f.tiles.maps.eox.at/wmts/',
],
layer: "terrain-light",
matrixSet: "WGS84",
format: "image/png",
projection: projection,
tileGrid: new ol.tilegrid.WMTS({
origin: ol.extent.getTopLeft(projection.getExtent()),
resolutions: resolutions,
matrixIds: matrixIds
}),
style: "default",
attributions: [
new ol.Attribution({
html: 'Data © <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors and <a href="/map_attribution.html">others</a>. Rendering © <a href="http://maps.eox.at" target="_blank">EOX</a>.'
})
],
})
}),
new ol.layer.Image({
source: new ol.source.ImageStatic({
url: canvas.toDataURL("image/png"),
imageExtent: [15.05, 47.75, 15.40, 47.95]
}),
extent: [15.05, 47.75, 15.40, 47.95]
})
],
view: new ol.View({
projection: projection,
center: [15.22, 47.85],
zoom: 10,
maxZoom: 13,
minZoom: 10,
extent: [15.15, 47.8, 15.3, 47.9]
})
});
});
});
};
});
</script>
</section>
<section>
<h2>Putting it Together</h2>
<iframe width="560" height="315" src="https://www.youtube.com/embed/qDazKJQBxuE" frameborder="0" allowfullscreen></iframe>
</section>
<section data-background="data/holuhraun.gif">
</section>
<section>
<h2>Future Work</h2>
<p>Compression: LZW and Deflate</p>
<p>Integrations with OpenLayers, Leaflet and Cesium</p>
</section>
<section>
<h2>Thank You!</h2>
<p>Any Questions?</p>
</section>
</div> <!-- .reveal -->
</div> <!-- .reveal -->
<script>
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'node_modules/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'node_modules/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'node_modules/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'node_modules/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'node_modules/reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'node_modules/reveal.js/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>