centroidOperator

ESM: import * as centroidOperator from "@arcgis/core/geometry/operators/centroidOperator.js";
CDN: const centroidOperator = await $arcgis.import("@arcgis/core/geometry/operators/centroidOperator.js");
Object: @arcgis/core/geometry/operators/centroidOperator
Since: ArcGIS Maps SDK for JavaScript 4.31

Calculates the centroid for a 2D geometry. The centroid represents the geometric center of mass, where the mass is equally distributed at each point/vertex of the geometry. For example, the centroid of a straight line is the midpoint. The centroid of a point is the point itself. It is not guaranteed to be within or on the geometry. The centroid of a donut polygon is the center of the hole, which is outside the polygon. The centroid of a curved polyline is not located on the line itself, but will be some distance away from it.

Centroid operator

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.