Skip to content

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

Notifications You must be signed in to change notification settings

miccferr/turf-inverse-distance-weighting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published