{"name":"@turf/center-median","version":"7.3.0","keywords":["turf","center-median"],"author":"Turf Authors","license":"MIT","_id":"@turf/center-median@7.3.0","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":["Moacir P. de Sá Pereira <@muziejus>"],"homepage":"https://github.com/Turfjs/turf","bugs":{"url":"https://github.com/Turfjs/turf/issues"},"dist":{"shasum":"5f1b86bb2d8dd0fc4a95350ec420e596971c0fd9","tarball":"http://registry-npm.ywwl.com/@turf/center-median/download/@turf/center-median-7.3.0.tgz","fileCount":9,"integrity":"sha512-Lp0kUGHM0HahZl54qb/B7zD3DXfFuBLhUS0t7fRlNfRywNUJSYh6SjCoLd1gYj7EFyOFWh4H8SUYgHDkh2U9oQ==","signatures":[{"sig":"MEUCIFDYirjV7HqX49A6wOvqMTZJoG1BF1db0Rp2DHInXkDvAiEAj18Bit9tMNFXD+qM4gy5F/SXRfWwX6rbyvYXDN3G9BA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37065,"size":7924,"noattachment":false,"key":"/@turf/center-median/-/@turf/center-median-7.3.0.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":"9f58a103e8f9a587ab640307ed03ba5233913ddd","scripts":{"docs":"tsx ../../scripts/generate-readmes.ts","test":"npm-run-all --npm-path npm 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/8.2.2/node@v20.19.5+x64 (linux)","description":"Takes a FeatureCollection of points and calculates the median center.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","dependencies":{"tslib":"^2.8.1","@turf/meta":"7.3.0","@turf/helpers":"7.3.0","@turf/centroid":"7.3.0","@turf/distance":"7.3.0","@types/geojson":"^7946.0.10","@turf/center-mean":"7.3.0"},"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","npm-run-all":"^4.1.5","@turf/center":"7.3.0","@turf/random":"7.3.0","@turf/truncate":"7.3.0","load-json-file":"^7.0.1","write-json-file":"^6.0.0","@types/benchmark":"^2.1.5","@turf/center-of-mass":"7.3.0"},"_npmOperationalInternal":{"tmp":"tmp/center-median_7.3.0_1763371537326_0.4090185669980566","host":"s3://npm-registry-packages-npm-production"},"readme":"# @turf/center-median\n\n<!-- Generated by documentation.js. Update this documentation by updating the source code. -->\n\n## centerMedian\n\nTakes a [FeatureCollection][1] of points and calculates the median center,\nalgorithimically. The median center is understood as the point that is\nrequires the least total travel from all other points.\n\nTurfjs has four different functions for calculating the center of a set of\ndata. Each is useful depending on circumstance.\n\n`@turf/center` finds the simple center of a dataset, by finding the\nmidpoint between the extents of the data. That is, it divides in half the\nfarthest east and farthest west point as well as the farthest north and\nfarthest south.\n\n`@turf/center-of-mass` imagines that the dataset is a sheet of paper.\nThe center of mass is where the sheet would balance on a fingertip.\n\n`@turf/center-mean` takes the averages of all the coordinates and\nproduces a value that respects that. Unlike `@turf/center`, it is\nsensitive to clusters and outliers. It lands in the statistical middle of a\ndataset, not the geographical. It can also be weighted, meaning certain\npoints are more important than others.\n\n`@turf/center-median` takes the mean center and tries to find, iteratively,\na new point that requires the least amount of travel from all the points in\nthe dataset. It is not as sensitive to outliers as `@turf/center-mean`, but it is\nattracted to clustered data. It, too, can be weighted.\n\n**Bibliography**\n\nHarold W. Kuhn and Robert E. Kuenne, “An Efficient Algorithm for the\nNumerical Solution of the Generalized Weber Problem in Spatial\nEconomics,” *Journal of Regional Science* 4, no. 2 (1962): 21–33,\ndoi:{@link [https://doi.org/10.1111/j.1467-9787.1962.tb00902.x}][2].\n\nJames E. Burt, Gerald M. Barber, and David L. Rigby, *Elementary\nStatistics for Geographers*, 3rd ed., New York: The Guilford\nPress, 2009, 150–151.\n\n### Parameters\n\n*   `features` **[FeatureCollection][1]\\<any>** Any GeoJSON Feature Collection\n*   `options` **[Object][3]** Optional parameters (optional, default `{}`)\n\n    *   `options.weight` **[string][4]?** the property name used to weight the center\n    *   `options.tolerance` **[number][5]** the difference in distance between candidate medians at which point the algorighim stops iterating. (optional, default `0.001`)\n    *   `options.counter` **[number][5]** how many attempts to find the median, should the tolerance be insufficient. (optional, default `10`)\n\n### Examples\n\n```javascript\nvar points = turf.points([[0, 0], [1, 0], [0, 1], [5, 8]]);\nvar medianCenter = turf.centerMedian(points);\n\n//addToMap\nvar addToMap = [points, medianCenter]\n```\n\nReturns **[Feature][6]<[Point][7]>** The median center of the collection\n\n[1]: https://tools.ietf.org/html/rfc7946#section-3.3\n\n[2]: https://doi.org/10.1111/j.1467-9787.1962.tb00902.x}\n\n[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object\n\n[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String\n\n[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number\n\n[6]: https://tools.ietf.org/html/rfc7946#section-3.2\n\n[7]: https://tools.ietf.org/html/rfc7946#section-3.1.2\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/center-median\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":1763371537510,"_cnpm_publish_time":1763371537510,"dist-tags":{"latest":"7.4.0","prerelease":"7.1.0-alpha.70"}}