geotiff-stats
Version:
Get Statistics from a Large GeoTIFF while Using a Low Amount of Memory
16 lines (11 loc) • 511 B
JavaScript
const calcStats = require("calc-stats");
const iterPixels = require("./iter-pixels");
module.exports = function calcBandStats({ image, bandIndex, calcStatsOptions = {} }) {
const noDataValue = image.getGDALNoData();
const pixels = iterPixels({ image, sample: bandIndex });
// clone to preserve immutabilty
calcStatsOptions = { ...calcStatsOptions };
calcStatsOptions.async = true;
if (noDataValue !== null) calcStatsOptions.noData = noDataValue;
return calcStats(pixels, calcStatsOptions);
};