index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { FeatureCollection } from "@turf/helpers";
  2. /**
  3. * Moran's I measures patterns of attribute values associated with features.
  4. * The method reveal whether similar values tend to occur near each other,
  5. * or whether high or low values are interspersed.
  6. *
  7. * Moran's I > 0 means a clusterd pattern.
  8. * Moran's I < 0 means a dispersed pattern.
  9. * Moran's I = 0 means a random pattern.
  10. *
  11. * In order to test the significance of the result. The z score is calculated.
  12. * A positive enough z-score (ex. >1.96) indicates clustering,
  13. * while a negative enough z-score (ex. <-1.96) indicates a dispersed pattern.
  14. *
  15. * the z-score can be calculated based on a normal or random assumption.
  16. *
  17. * **Bibliography***
  18. *
  19. * 1. [Moran's I](https://en.wikipedia.org/wiki/Moran%27s_I)
  20. *
  21. * 2. [pysal](http://pysal.readthedocs.io/en/latest/index.html)
  22. *
  23. * 3. Andy Mitchell, The ESRI Guide to GIS Analysis Volume 2: Spatial Measurements & Statistics.
  24. *
  25. * @name moranIndex
  26. * @param {FeatureCollection<any>} fc
  27. * @param {Object} options
  28. * @param {string} options.inputField the property name, must contain numeric values
  29. * @param {number} [options.threshold=100000] the distance threshold
  30. * @param {number} [options.p=2] the Minkowski p-norm distance parameter
  31. * @param {boolean} [options.binary=false] whether transfrom the distance to binary
  32. * @param {number} [options.alpha=-1] the distance decay parameter
  33. * @param {boolean} [options.standardization=true] wheter row standardization the distance
  34. * @returns {MoranIndex}
  35. * @example
  36. *
  37. * const bbox = [-65, 40, -63, 42];
  38. * const dataset = turf.randomPoint(100, { bbox: bbox });
  39. *
  40. * const result = turf.moranIndex(dataset, {
  41. * inputField: 'CRIME',
  42. * });
  43. */
  44. export default function (fc: FeatureCollection<any>, options: {
  45. inputField: string;
  46. threshold?: number;
  47. p?: number;
  48. binary?: boolean;
  49. alpha?: number;
  50. standardization?: boolean;
  51. }): {
  52. moranIndex: number;
  53. expectedMoranIndex: number;
  54. stdNorm: number;
  55. zNorm: number;
  56. };
  57. /**
  58. * @typedef {Object} MoranIndex
  59. * @property {number} moranIndex the moran's Index of the observed feature set
  60. * @property {number} expectedMoranIndex the moran's Index of the random distribution
  61. * @property {number} stdNorm the standard devitaion of the random distribution
  62. * @property {number} zNorm the z-score of the observe samples with regard to the random distribution
  63. */