Skip to main content
Version: 6.5.0

distanceWeight

Description

Parameters

NameTypeDescription
fcFeatureCollection<any>FeatureCollection.
options?Objectoption object.
options.threshold?numberIf the distance between neighbor and target features is greater than threshold, the weight of that neighbor is 0. (default 10000)
options.p?numberMinkowski p-norm distance parameter. 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity. (default 2)
options.binary?booleanIf true, weight=1 if d <= threshold otherwise weight=0. If false, weight=Math.pow(d, alpha). (default false)
options.alpha?numberdistance decay parameter. A big value means the weight decay quickly as distance increases. (default -1)
options.standardization?booleanrow standardization. (default false)

Returns

    Array<Array<number>> distance weight matrix.

Examples

var bbox = [-65, 40, -63, 42];
var dataset = turf.randomPoint(100, { bbox: bbox });
var result = turf.distanceWeight(dataset);

Installation

$ npm install @turf/distance-weight

import { distanceWeight } from "@turf/distance-weight";
const result = distanceWeight(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.distanceWeight(...);