Skip to content
import AreaMeasurementAnalysis from "@arcgis/core/analysis/AreaMeasurementAnalysis.js";
Inheritance:
AreaMeasurementAnalysisAnalysisAccessor
Since
ArcGIS Maps SDK for JavaScript 4.23

AreaMeasurementAnalysis computes the area of a polygonal region and displays the measurement in a View.

To display an area measurement of a Polygon, create a new instance of AreaMeasurementAnalysis, add it to SceneView.analyses or MapView.analyses and set the geometry property.

Use the AreaMeasurementAnalysisView2D or AreaMeasurementAnalysisView3D to retrieve analysis results.

// create analysis
const areaMeasurement = new AreaMeasurementAnalysis({
geometry: new Polygon({ })
});
// add to a view
view.analyses.add(areaMeasurement);
// retrieve measured results from analysis view once available
const analysisView = await view.whenAnalysisView(areaMeasurement);
await reactiveUtils.whenOnce(() => analysisView.result);
const result = analysisView.result;

To draw an area measurement interactively, use the AreaMeasurementAnalysisView2D.place() or AreaMeasurementAnalysisView3D.place() method.

const abortController = new AbortController();
try {
await analysisView.place({ signal: abortController.signal });
} catch (error) {
if (error.name === "AbortError") {
console.log("Placement operation was cancelled.");
}
}
// cancel the placement operation at some later point
abortController.abort();

How the area and perimeter are calculated depends on the view type, the spatial reference, and the measured perimeter.

  • In a MapView (2D):

    • For geographic coordinate systems (GCS) and Web Mercator, measurements are calculated geodetically (on the ellipsoid).
    • For projected coordinate systems (PCS), apart from Web Mercator, the area and perimeter are always calculated using Euclidean geometry within their respective PCS.
  • In a SceneView (3D):

    • For geographic coordinate systems (GCS) and Web Mercator, short measurements use a Euclidean computation in an ECEF (Earth-Centered, Earth-Fixed) coordinate system (or an equivalent on other planets). Specifically, if the measurement's perimeter is ≤ 100 km the analysis uses Euclidean calculations. If the perimeter is > 100 km, it uses geodetic calculations.
    • For projected coordinate systems (PCS), apart from Web Mercator, the area and perimeter are always calculated in a Euclidean (in their respective PCS).
    • The area may be visualized and calculated in one of two ways:
      1. If the vertices are (approximately) coplanar, a measurement polygon is formed on that plane. The area and perimeter are then computed from the polygon geometry.
      2. If the vertices do not form a planar surface, the measurement polygon is projected to a horizontal plane and the area and perimeter are computed from the projected geometry.

area-measurement-3d-types

Use the Area Measurement 3D component to display a user interface for the area measurement analysis.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
declaredClass
readonly inherited
id
readonly inherited
origin
inherited
type
readonly
"area-measurement"
uid
readonly inherited
valid
readonly

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

geometry

autocast Property
Type
Polygon | null | undefined

Polygon whose area is to be computed and displayed in the view.

If the polygon has z-values then these will be treated as absolute values.

Known Limitation

For polygons with multiple rings, only the measurement of the first ring will be displayed.

id

readonlyinherited Property
Type
string
Inherited from: Analysis

A user settable identifier for the analysis. A unique value is automatically generated when the analysis is created if it is not set explicitly during construction.

origin

autocast inherited Property
Type
AnalysisOriginWebScene | null | undefined
Inherited from: Analysis

The origin of the analysis. The origin can be of type web-scene when the analysis was applied from the WebScene.initialViewProperties or a Slide.

type

readonly Property
Type
"area-measurement"

The type of analysis. For area measurement analysis, this is always "area-measurement".

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

unit

Property
Type
SystemOrAreaUnit | null | undefined

Unit system (imperial, metric) or specific unit used for displaying the computed area in the view.

valid

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.33

Indicates whether the analysis is ready to be computed and interacted with in the view. It requires the geometry to be a valid polygon whose first ring contains at least 4 points, with the first and last points being the same to close the polygon.

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clear(): void
clone
inherited
clone(): this
equals
inherited
equals(other: this): boolean
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters
ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

clear

Method
Signature
clear (): void
Since
ArcGIS Maps SDK for JavaScript 5.0

Clears the analysis by resetting the geometry property.

Returns
void

clone

inherited Method
Signature
clone (): this
Inherited from: ClonableMixin

Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.

Returns
this

A deep clone of the class instance that invoked this method.

equals

inherited Method
Signature
equals (other: this): boolean
Inherited from: Analysis
Since
ArcGIS Maps SDK for JavaScript 5.0

Compares this analysis with another analysis to determine whether they are equivalent.

Parameters
ParameterTypeDescriptionRequired
other

The other analysis to compare against.

Returns
boolean

true if the analyses are equivalent and false otherwise.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.