Today a plain IDW alg. implemented in JS. Tomorrow a Turf.js package? Maybe?
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
tests refactored index code & add tests Apr 21, 2016
.gitignore update .gitignore Apr 21, 2016
README.md update README.md Aug 16, 2016
celebration.gif success! module accepted on TurfJs. Update README.md Aug 16, 2016
index.js fixed valueField bug Apr 22, 2016
package.json refactored index code & add tests Apr 21, 2016
test.js cleaned blank lines Apr 21, 2016

README.md

turf-idw

Today a plain IDW alg. implemented in JS. Tomorrow a Turf.js package? Maybe?

UPDATE:


The module has been accepted and is now officially part of TurfJs! You can find it on Turf's repo or as a stand-alone module on npm thanks to @tmcw and @morganherlocker.

Obligatory happy celebratory gif:

Usage:


IDW(controlPoints, valueField, b, cellWidth, units)

Takes a set of known sampled points, a property containing data value, an exponent parameter, a cell depth, a unit of measurement and returns a set of square polygons in a grid with an IDW value for each cell.

Based on the Inverse Distance Weighting interpolation algorithm as covered in the following (among other) resources: [1], [2].

Parameters

parameter type description
controlPoints FeatureCollection Sampled points with known value
valueField String GeoJSON field containing the data value to interpolate on
b Number Exponent regulating the distance weighting
cellWidth Number The distance across each cell
units String Used in calculating cellWidth ('miles' or 'kilometers')

Example

// load IDW
var IDW = require('./index.js')

// load a sample of test points
var fs = require('fs');
var controlPoints = JSON.parse(fs.readFileSync('./data/data.geojson'));

// produce an interpolated surface
var IDWSurface = IDW(controlPoints,'value', 0.5, 0.1,'kilometers');

Installation & Use

Requires nodejs.

Git clone this repo, then require it

Tests

$ npm test

Resources

[1] O’Sullivan, D., & Unwin, D. (2010). Geographic Information Analysis (2nd Edition). 432pp. Hoboken, New Jersey (USA): John Wiley & Sons, Inc.

[2] Xiao, N. (2016). GIS Algorithms, 336pp. SAGE Publications Ltd.