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

Calculates the centroid for a 2D geometry.

Property Overview

Name Type Summary Object

Indicates if the operator supports input geometries that contain curves.

centroidOperator

Property Details

supportsCurves

Property
supportsCurves Booleanreadonly

Indicates if the operator supports input geometries that contain curves.

Default Value:true

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 GeometryUnion

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.