index.d.ts 2.4 KB

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