index.d.cts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { FeatureCollection, Point } from 'geojson';
  2. interface QuadratAnalysisResult {
  3. criticalValue: number;
  4. maxAbsoluteDifference: number;
  5. isRandom: boolean;
  6. observedDistribution: number[];
  7. }
  8. /**
  9. * Quadrat analysis lays a set of equal-size areas(quadrat) over the study area and counts
  10. * the number of features in each quadrat and creates a frequency table.
  11. * The table lists the number of quadrats containing no features,
  12. * the number containing one feature, two features, and so on,
  13. * all the way up to the quadrat containing the most features.
  14. * The method then creates the frequency table for the random distribution, usually based on a Poisson distribution.
  15. * The method uses the distribution to calculate the probability for 0 feature occuring,
  16. * 1 feature occuring, 2 features, and so on,
  17. * and lists these probabilities in the frequency table.
  18. * By comparing the two frequency tables, you can see whether the features create a pattern.
  19. * If the table for the observed distribution has more quadrats containing many features than the
  20. * table for the random distribution dose, then the features create a clustered pattern.
  21. *
  22. * It is hard to judge the frequency tables are similar or different just by looking at them.
  23. * So, we can use serval statistical tests to find out how much the frequency tables differ.
  24. * We use Kolmogorov-Smirnov test.This method calculates cumulative probabilities for both distributions,
  25. * and then compares the cumulative probabilities at each class level and selects the largest absolute difference D.
  26. * Then, the test compares D to the critical value for a confidence level you specify.
  27. * If D is greater than the critical value, the difference between the observed distribution and
  28. * the random distribution is significant. The greater the value the bigger the difference.
  29. *
  30. * Traditionally, squares are used for the shape of the quadrats, in a regular grid(square-grid).
  31. * Some researchers suggest that the quadrat size equal twice the size of mean area per feature,
  32. * which is simply the area of the study area divided by the number of features.
  33. *
  34. *
  35. * @function
  36. * @param {FeatureCollection<Point>} pointFeatureSet point set to study
  37. * @param {Object} [options={}] optional parameters
  38. * @param {[number, number, number, number]} [options.studyBbox] bbox representing the study area
  39. * @param {20 | 15 | 10 | 5 | 2 | 1} [options.confidenceLevel=20] a confidence level.
  40. * The unit is percentage . 5 means 95%, value must be in {@link K_TABLE}
  41. * @returns {QuadratAnalysisResult} result
  42. * @example
  43. *
  44. * var bbox = [-65, 40, -63, 42];
  45. * var dataset = turf.randomPoint(100, { bbox: bbox });
  46. * var result = turf.quadratAnalysis(dataset);
  47. *
  48. */
  49. declare function quadratAnalysis(pointFeatureSet: FeatureCollection<Point>, options: {
  50. studyBbox?: [number, number, number, number];
  51. confidenceLevel?: 20 | 15 | 10 | 5 | 2 | 1;
  52. }): QuadratAnalysisResult;
  53. export { type QuadratAnalysisResult, quadratAnalysis as default, quadratAnalysis };