index.d.ts 926 B

12345678910111213141516171819202122
  1. import { AllGeoJSON, Feature, Point, Properties } from "@turf/helpers";
  2. /**
  3. * Takes one or more features and calculates the centroid using the mean of all vertices.
  4. * This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
  5. *
  6. * @name centroid
  7. * @param {GeoJSON} geojson GeoJSON to be centered
  8. * @param {Object} [options={}] Optional Parameters
  9. * @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties
  10. * @returns {Feature<Point>} the centroid of the input features
  11. * @example
  12. * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
  13. *
  14. * var centroid = turf.centroid(polygon);
  15. *
  16. * //addToMap
  17. * var addToMap = [polygon, centroid]
  18. */
  19. declare function centroid<P = Properties>(geojson: AllGeoJSON, options?: {
  20. properties?: P;
  21. }): Feature<Point, P>;
  22. export default centroid;