This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Fabian Schindler
Source code: https://github.com/geotiffjs/geotiff.js/
Documentation: https://geotiffjs.github.io/geotiff.js/
Since v0.4.1: rewrite
v1.0.0 is around the corner(-ish)
(COG) - https://www.cogeo.org/
Efficient access to subsets of large raster files
(... even via network)
Header
Endianness
bigtiff?
first IFD
IFD 1
size
tag 1
tag 2
...
next IFD
IFD 2
size
tag 1
tag 2
...
next IFD
IFD n
size
tag 1
tag 2
...
next IFD
IFD
ID - 1 | type | ||
ID - 2 | type | ||
ID - 3 | type | ||
... | |||
Value
Value
Value
Reference
Value
IFD
... | |||
... | |||
ID | type | ||
... | |||
... |
Reference
Reference |
Reference |
Reference |
Reference |
Raster data
Raster data
Raster data
Raster data
Header
IFD
IFD Data
Raster Data
Header
IFD-1
IFD-1 Data
Raster Data n
...
IFD-2
IFD-2 Data
IFD-n
IFD-n Data
...
Raster Data n-1
...
Raster Data 1
...
image size
image size
Handled by Reader/Decoder
GET /file.tiff HTTP/1.1
Host: example.com
Range: bytes=0-1023
→ an additional abstraction layer needed
Handled by Source
Raw bytes
Tiles / rows
Data Arrays
Source
Reader
Decoder
low-level
Output → uniform RGB
const source = {
async fetch(offset, length) {
// ...
return data; // ArrayBuffer instance
}
};
GET /file.tiff HTTP/1.1
Host: example.com
Range: bytes=0-1023
IFD
IFD Data
Raster Data
import GeoTIFF from 'geotiff';
// ...
const tiff = await GeoTIFF.fromUrl(someUrl);
const image = await tiff.getImage();
const width = image.getWidth();
const height = image.getHeight();
const tileWidth = image.getTileWidth();
const tileHeight = image.getTileHeight();
const samplesPerPixel = image.getSamplesPerPixel();
const origin = image.getOrigin();
const resolution = image.getResolution();
const bbox = image.getBoundingBox();
Importing, loading and metadata
const data = await image.readRasters();
const { width, height } = data;
const left = 50;
const top = 10;
const right = 150;
const bottom = 60;
const data = await image.readRasters({
window: [left, top, right, bottom],
width: 100,
height: 100,
resampleMethod: 'bilinear',
});
const data = await tiff.readRasters({
bbox: [10.34, 57.28, 13.34, 60.23],
resX: 0.1,
resY: 0.1
});
Read raster from TIFF
Read raster from specific image
Subsetting / Scaling
<input type="file" id="file">
<script>
const input = document.getElementById('file'):
input.onchange = async function() {
const tiff = await GeoTIFF.fromBlob(input.files[0]);
}
</script>
const tiff = await GeoTIFF.fromUrls(
'LC08_L1TP_189027_20170403_20170414_01_T1_B3.TIF',
['LC08_L1TP_189027_20170403_20170414_01_T1_B3.TIF.ovr']
);
const tiff = await GeoTIFF.GeoTIFF.fromSource({
async fetch(offset, length) {
// ...
return data;
}
});
Contributions are welcome!