index.d.cts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Position, Feature, Polygon, FeatureCollection, Point, GeoJsonProperties } from 'geojson';
  2. declare interface SDEProps {
  3. meanCenterCoordinates: Position;
  4. semiMajorAxis: number;
  5. semiMinorAxis: number;
  6. numberOfFeatures: number;
  7. angle: number;
  8. percentageWithinEllipse: number;
  9. }
  10. declare interface StandardDeviationalEllipse extends Feature<Polygon> {
  11. properties: {
  12. standardDeviationalEllipse: SDEProps;
  13. [key: string]: any;
  14. } | null;
  15. }
  16. /**
  17. * Takes a collection of features and returns a standard deviational ellipse,
  18. * also known as a “directional distribution.” The standard deviational ellipse
  19. * aims to show the direction and the distribution of a dataset by drawing
  20. * an ellipse that contains about one standard deviation’s worth (~ 70%) of the
  21. * data.
  22. *
  23. * This module mirrors the functionality of {@link http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm|Directional Distribution}
  24. * in ArcGIS and the {@link http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/|QGIS Standard Deviational Ellipse Plugin}
  25. *
  26. * **Bibliography**
  27. *
  28. * • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for
  29. * Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,
  30. * doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.
  31. *
  32. * • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”
  33. * _American Journal of Sociology_ 33, no. 1 (1927): 94—98,
  34. * doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.
  35. *
  36. *
  37. * @function
  38. * @param {FeatureCollection<Point>} points GeoJSON points
  39. * @param {Object} [options={}] Optional parameters
  40. * @param {string} [options.weight] the property name used to weight the center
  41. * @param {number} [options.steps=64] number of steps for the polygon
  42. * @param {Object} [options.properties={}] properties to pass to the resulting ellipse
  43. * @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.
  44. * @example
  45. *
  46. * const bbox = [-74, 40.72, -73.98, 40.74];
  47. * const points = turf.randomPoint(400, {bbox: bbox});
  48. * const sdEllipse = turf.standardDeviationalEllipse(points);
  49. *
  50. * //addToMap
  51. * const addToMap = [points, sdEllipse];
  52. *
  53. */
  54. declare function standardDeviationalEllipse(points: FeatureCollection<Point>, options?: {
  55. properties?: GeoJsonProperties;
  56. weight?: string;
  57. steps?: number;
  58. }): StandardDeviationalEllipse;
  59. export { type SDEProps, type StandardDeviationalEllipse, standardDeviationalEllipse as default, standardDeviationalEllipse };