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.

The developer dashboard has moved

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close