JSPM

  • Created
  • Published
  • Downloads 587356
  • Score
    100M100P100Q295166F
  • License MIT

turf distance-weight module

Package Exports

  • @turf/distance-weight

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@turf/distance-weight) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@turf/distance-weight

pNormDistance

calcualte the Minkowski p-norm distance between two features.

Parameters

  • feature1 point feature
  • feature2 point feature
  • p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance

distanceWeight

Parameters

  • fc FeatureCollection<any> FeatureCollection.
  • options Object? option object.
    • options.threshold number If the distance between neighbor and target features is greater than threshold, the weight of that neighbor is 0. (optional, default 10000)
    • options.p number Minkowski p-norm distance parameter. 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity. (optional, default 2)
    • options.binary boolean If true, weight=1 if d <= threshold otherwise weight=0. If false, weight=Math.pow(d, alpha). (optional, default false)
    • options.alpha number distance decay parameter. A big value means the weight decay quickly as distance increases. (optional, default -1)
    • options.standardization boolean row standardization. (optional, default false)

Examples

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

Returns Array<Array<number>> distance weight matrix.


This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.

Installation

Install this module individually:

$ npm install @turf/distance-weight

Or install the Turf module that includes it as a function:

$ npm install @turf/turf