Skip to content

Commit 48b0356

Browse files
committed
Merge branch 'master' of github.com:GeoTIFF/geotiff-stats
2 parents 74ed15f + 935e380 commit 48b0356

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Diff for: README.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
# geotiff-stats
2-
Get Statistics from a GeoTIFF without Crashing Your Browser
2+
Get Statistics from a Large GeoTIFF without Crashing Your Browser
3+
4+
# install
5+
`npm install geotiff-stats`
6+
7+
# problem
8+
I wanted to load a Landsat scene into geotiff.io, but my Chromebook couldn't load all the values into memory in order to calculate the minimum and maximum. This package was created, in order to enable people on low-memory devices to iteratively loop over pixel values in a GeoTIFF image and calculate aggregate statistics like minimum and maximum.
39

410
# usage
511
```javascript
6-
import { getStats } from 'geotiff-stats';
12+
const { readFileSync } = require('fs');
13+
const { fromArrayBuffer } = require('geotiff');
14+
const { getStats } = require('geotiff-stats');
15+
716

8-
const stats = await getStats(image, { maximum: true, minimum: true, bufferSize: 10000 });
17+
const data = readFileSync('LC80120312013106LGN01_B6.tif');
18+
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
19+
const geotiff = await fromArrayBuffer(arrayBuffer);
20+
const image = await geotiff.getImage();
21+
const results = await getStats(image);
22+
console.log(results);
23+
// { bands: [{ min: 0, max: 62196 }] }
924
```
25+
26+
# accessing data from a specific band
27+
getStats returns an object with the max and min for each band. You can access the max for the 3rd band (index of 2) with the following: `results.bands[2].max`
28+
29+
# contact
30+
Post an issue at https://github.com/GeoTIFF/geotiff-stats/issues or email the package author Daniel J. Dufour at [email protected]

0 commit comments

Comments
 (0)