@millcrest/polygonize-wasm
v0.1.0
Published
JS/WASM library to compute isolines and isobands (using GDAL-style pixel-boundary polygonization)
Readme
@millcrest/polygonize-wasm
WASM library for computing isolines, isobands, and GDAL-style polygon rasterization.
Installation
npm install @millcrest/polygonize-wasmFunctions
polygonize
Converts a raster grid to polygons where output boundaries align exactly with pixel edges (GDAL-style).
import { polygonize } from '@millcrest/polygonize-wasm';
const data = [
1, 1, 2,
1, 2, 2,
3, 3, 2,
];
const result = polygonize(data, 3, 3);
// Returns GeoJSON FeatureCollection with one polygon per unique valueisobands
Computes filled contour polygons using marching squares interpolation.
import { isobands } from '@millcrest/polygonize-wasm';
const data = [
0, 0, 0, 0,
0, 2, 2, 0,
0, 2, 2, 0,
0, 0, 0, 0,
];
const result = isobands(data, 4, 4, [0, 1.5, 3]);Options:
const options = {
use_quad_tree: false, // default: true
x_origin: 0, // default: 0
y_origin: 0, // default: 0
x_step: 1, // default: 1
y_step: 1, // default: 1
};
const result = isobands(data, 4, 4, [0, 1.5, 3], options);isolines
Computes contour lines using marching squares interpolation.
import { isolines } from '@millcrest/polygonize-wasm';
const result = isolines(data, 4, 4, [0, 1.5, 3]);Same options as isobands.
Build
make buildTest
make test