centroidOperator

AMD: require(["esri/geometry/operators/centroidOperator"], (centroidOperator) => { /* code goes here */ });
ESM: import * as centroidOperator from "@arcgis/core/geometry/operators/centroidOperator.js";
Object: esri/geometry/operators/centroidOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

Calculates the centroid for a 2D geometry.

Method Overview

Name Return Type Summary Object

Performs the centroid operation on a geometry.

centroidOperator

Method Details

execute

Method
execute(geometry){Point}

Performs the centroid operation on a geometry.

Parameter
geometry Geometry

The geometry in which to calculate the centroid.

Returns
Type Description
Point The centroid of the geometry.
Example
// Return the centroid of a polygon
const centroid = operatorCentroid.execute(polygon);
console.log(`x: ${centroid.x}, y: ${centroid.y}`);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.