{"name":"@turf/nearest-neighbor-analysis","version":"7.3.2","keywords":["turf","nearest-neighbor"],"author":{"name":"Turf Authors"},"license":"MIT","_id":"@turf/nearest-neighbor-analysis@7.3.2","maintainers":[{"name":"rowanwins","email":"rowanwins@yahoo.com.au"},{"name":"tmcw","email":"tom@macwright.com"},{"name":"morganherlocker","email":"morgan.herlocker@gmail.com"},{"name":"tcql","email":"tim.channell@gmail.com"},{"name":"mdfedderly","email":"mdfedderly@mdfedderly.com"},{"name":"twelch","email":"tim.j.welch@gmail.com"},{"name":"jamesmilneruk","email":"jamesmilner22@hotmail.com"},{"name":"morgan.herlocker","email":"morganherlocker@gmail.com"},{"name":"smallsaucepan","email":"james@smallsaucepan.com"}],"contributors":[{"name":"Moacir P. de Sá Pereira","email":"@muziejus"}],"homepage":"https://github.com/Turfjs/turf","bugs":{"url":"https://github.com/Turfjs/turf/issues"},"dist":{"shasum":"3fe2339ba7c70d94055852a1335b2769b2b5e3ea","tarball":"http://registry-npm.ywwl.com/@turf/nearest-neighbor-analysis/download/@turf/nearest-neighbor-analysis-7.3.2.tgz","fileCount":9,"integrity":"sha512-TzC/DiKVW649AAD9VCagXtJ26GaYgk5uaeOB8LMf1771o2BiBHCshiYqzl22hl8A02gWIEn/kTdo2O2SiwYivQ==","signatures":[{"sig":"MEUCIQCWFZA7KxCqbRZiF6FVB1QwWwxLNcaunJ/Em/suKW2TwgIgUnjjvd9xLfe+SHx+m2FBoLGVWJRgbfzZRW5FX9O6X4A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35749,"size":7607,"noattachment":false,"key":"/@turf/nearest-neighbor-analysis/-/@turf/nearest-neighbor-analysis-7.3.2.tgz"},"main":"dist/cjs/index.cjs","type":"module","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.cts","default":"./dist/cjs/index.cjs"}},"./package.json":"./package.json"},"funding":"https://opencollective.com/turf","gitHead":"099d9915467bacf45d554be4533fa9998c4efc88","scripts":{"docs":"tsx ../../scripts/generate-readmes.ts","test":"pnpm run /test:.*/","bench":"tsx bench.ts","build":"tsup --config ../../tsup.config.ts","test:tape":"tsx test.ts"},"_npmUser":{"name":"mdfedderly","email":"mdfedderly@mdfedderly.com"},"repository":{"url":"git://github.com/Turfjs/turf.git","type":"git"},"_npmVersion":"lerna/9.0.3/node@v20.19.6+x64 (linux)","description":"Calculates an index based the average distances between points in the dataset, thereby providing inference as to whether the data is clustered, dispersed, or randomly distributed within the study area.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.6","dependencies":{"tslib":"^2.8.1","@turf/area":"7.3.2","@turf/bbox":"7.3.2","@turf/meta":"7.3.2","@turf/helpers":"7.3.2","@turf/centroid":"7.3.2","@turf/distance":"7.3.2","@types/geojson":"^7946.0.10","@turf/bbox-polygon":"7.3.2","@turf/nearest-point":"7.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.4","tape":"^5.9.0","tsup":"^8.4.0","benchmark":"^2.1.4","typescript":"^5.8.3","@types/tape":"^5.8.1","@turf/truncate":"7.3.2","load-json-file":"^7.0.1","write-json-file":"^6.0.0","@types/benchmark":"^2.1.5"},"_npmOperationalInternal":{"tmp":"tmp/nearest-neighbor-analysis_7.3.2_1768358886295_0.27271664140489116","host":"s3://npm-registry-packages-npm-production"},"readme":"# @turf/nearest-neighbor-analysis\n\n<!-- Generated by documentation.js. Update this documentation by updating the source code. -->\n\n## NearestNeighborStatistics\n\nNearest neighbour statistics.\n\nType: [object][1]\n\n### Properties\n\n*   `arealUnits` **[string][2]**&#x20;\n*   `observedMeanDistance` **[number][3]**&#x20;\n*   `expectedMeanDistance` **[number][3]**&#x20;\n*   `numberOfPoints` **[number][3]**&#x20;\n*   `zScore` **[number][3]**&#x20;\n\n## NearestNeighborStudyArea\n\nNearest neighbour study area polygon feature.\n\nType: [object][1]\n\n### Properties\n\n*   `properties` **[GeoJsonProperties][4]**&#x20;\n\n    *   `properties.nearestNeighborAnalysis` **[NearestNeighborStatistics][5]**&#x20;\n\n## nearestNeighborAnalysis\n\nNearest Neighbor Analysis calculates an index based on the average distances\nbetween points in the dataset, thereby providing inference as to whether the\ndata is clustered, dispersed, or randomly distributed within the study area.\n\nIt returns a [Feature][4]<[Polygon][6]> of the study area, with the results of\nthe analysis attached as part of of the `nearestNeighborAnalysis` property\nof the study area's `properties`. The attached\n[*z*-score][7] indicates how many\nstandard deviations above or below the expected mean distance the data's\nobserved mean distance is. The more negative, the more clustered. The more\npositive, the more evenly dispersed. A *z*-score between -2 and 2 indicates\na seemingly random distribution. That is, within *p* of less than 0.05, the\ndistribution appears statistically significantly neither clustered nor\ndispersed.\n\n**Remarks**\n\n*   Though the analysis will work on any [FeatureCollection][8] type, it\n    works best with [Point][9] collections.\n\n*   This analysis is *very* sensitive to the study area provided.\n    If no [Feature][4]<[Polygon][6]> is passed as the study area, the function draws a box\n    around the data, which may distort the findings. This analysis works best\n    with a bounded area of interest within with the data is either clustered,\n    dispersed, or randomly distributed. For example, a city's subway stops may\n    look extremely clustered if the study area is an entire state. On the other\n    hand, they may look rather evenly dispersed if the study area is limited to\n    the city's downtown.\n\n**Bibliography**\n\nPhilip J. Clark and Francis C. Evans, “Distance to Nearest Neighbor as a\nMeasure of Spatial Relationships in Populations,” *Ecology* 35, no. 4\n(1954): 445–453, doi:[10.2307/1931034][10].\n\n### Parameters\n\n*   `dataset` **[FeatureCollection][8]\\<any>** FeatureCollection (pref. of points) to study\n*   `options` **[Object][1]** Optional parameters (optional, default `{}`)\n\n    *   `options.studyArea` **[Feature][4]<[Polygon][6]>?** polygon representing the study area\n    *   `options.properties` **[GeoJsonProperties][4]** properties (optional, default `{}`)\n\n### Examples\n\n```javascript\nvar bbox = [-65, 40, -63, 42];\nvar dataset = turf.randomPoint(100, { bbox: bbox });\nvar nearestNeighborStudyArea = turf.nearestNeighborAnalysis(dataset);\n\n//addToMap\nvar addToMap = [dataset, nearestNeighborStudyArea];\n```\n\nReturns **[NearestNeighborStudyArea][11]** A polygon of the study area or an approximation of one.\n\n[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\n\n[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String\n\n[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number\n\n[4]: https://tools.ietf.org/html/rfc7946#section-3.2\n\n[5]: #nearestneighborstatistics\n\n[6]: https://tools.ietf.org/html/rfc7946#section-3.1.6\n\n[7]: https://en.wikipedia.org/wiki/Standard_score\n\n[8]: https://tools.ietf.org/html/rfc7946#section-3.3\n\n[9]: https://tools.ietf.org/html/rfc7946#section-3.1.2\n\n[10]: http://doi.org/10.2307/1931034\n\n[11]: #nearestneighborstudyarea\n\n<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run \"yarn docs\" from the root of the turf project. -->\n\n---\n\nThis module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.\n\n### Installation\n\nInstall this single module individually:\n\n```sh\n$ npm install @turf/nearest-neighbor-analysis\n```\n\nOr install the all-encompassing @turf/turf module that includes all modules as functions:\n\n```sh\n$ npm install @turf/turf\n```\n","publish_time":1768358886435,"_cnpm_publish_time":1768358886435,"dist-tags":{"latest":"7.4.0","prerelease":"7.1.0-alpha.70"}}