index.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Feature, FeatureCollection, Point } from "@turf/helpers";
  2. /**
  3. * calcualte the Minkowski p-norm distance between two features.
  4. * @param feature1 point feature
  5. * @param feature2 point feature
  6. * @param p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
  7. */
  8. export declare function pNormDistance(feature1: Feature<Point>, feature2: Feature<Point>, p?: number): number;
  9. /**
  10. *
  11. *
  12. * @name distanceWeight
  13. * @param {FeatureCollection<any>} fc FeatureCollection.
  14. * @param {Object} [options] option object.
  15. * @param {number} [options.threshold=10000] If the distance between neighbor and
  16. * target features is greater than threshold, the weight of that neighbor is 0.
  17. * @param {number} [options.p=2] Minkowski p-norm distance parameter.
  18. * 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
  19. * @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
  20. * If false, weight=Math.pow(d, alpha).
  21. * @param {number} [options.alpha=-1] distance decay parameter.
  22. * A big value means the weight decay quickly as distance increases.
  23. * @param {boolean} [options.standardization=false] row standardization.
  24. * @returns {Array<Array<number>>} distance weight matrix.
  25. * @example
  26. *
  27. * var bbox = [-65, 40, -63, 42];
  28. * var dataset = turf.randomPoint(100, { bbox: bbox });
  29. * var result = turf.distanceWeight(dataset);
  30. */
  31. export default function distanceWeight(fc: FeatureCollection<any>, options?: {
  32. threshold?: number;
  33. p?: number;
  34. binary?: boolean;
  35. alpha?: number;
  36. standardization?: boolean;
  37. }): number[][];