import ElevationProfileAnalysis from "@arcgis/core/analysis/ElevationProfileAnalysis.js";const ElevationProfileAnalysis = await $arcgis.import("@arcgis/core/analysis/ElevationProfileAnalysis.js");- Since
- ArcGIS Maps SDK for JavaScript 4.34
The ElevationProfileAnalysis class enables programmatic creation and management of elevation profiles in both,
a SceneView and a MapView. An elevation profile visualizes elevation
changes along a specified Polyline, which is provided via the geometry property.
This analysis supports multiple profile lines, each representing a different source or method for sampling elevation, such as ground, input geometry, custom elevation sources, or scene content. The configuration of these lines is managed through the profiles property.
To add an elevation profile analysis to a view:
const elevationProfileAnalysis = new ElevationProfileAnalysis({ profiles: [ // Profile line that samples the ground elevation { type: "ground", color: "rgb(150, 75, 0)", } ], geometry: new Polyline({ })});
view.analyses.add(elevationProfileAnalysis);The MapView.analyses and SceneView.analyses collections can contain multiple elevation profile analyses simultaneously.
Use the ElevationProfileAnalysisView2D or ElevationProfileAnalysisView3D to retrieve the analysis results. The combined statistics, as well as results for each computed profile line, can be then visualized in a custom chart using any charting library, embedded in a dashboard, exported as a CSV file, or used for further calculations.
// Get the analysis viewconst analysisView = await view.whenAnalysisView(elevationProfileAnalysis);// Retrieve the results, once they are readyreactiveUtils.watch( () => analysisView.progress, (progress) => { if (progress === 1) { console.log("Results are computed", analysisView.results); console.log("Statistics are computed", analysisView.statistics); } });To interactively place an elevation profile, use the ElevationProfileAnalysisView2D.place() or ElevationProfileAnalysisView3D.place() methods.
const abortController = new AbortController();
try { // Start placing a new profile line interactively await analysisView.place({ signal: abortController.signal });} catch (error) { if (error.name === "AbortError") { console.log("Placement operation was cancelled."); }}
// Cancel the operation at some later pointabortController.abort();How distances are computed depends on the scene's or map's spatial reference:
- In geographic coordinate systems (GCS) and in Web Mercator, distances are computed geodetically, taking the curvature of the planet into consideration.
- In projected coordinate systems (PCS), apart from Web Mercator, the distances are computed in a Euclidean manner (in their respective PCS).
For a ready-to-use UI, use the Elevation Profile component, which allows users to interactively place an elevation profile and view the results in a chart.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
displayUnits
Unit systems (imperial, metric) or specific units used for computing and displaying elevation profile results.
If not specified, units are chosen automatically based on the magnitude of the results. The effective units can be accessed through the ElevationProfileAnalysisView2D.results or ElevationProfileAnalysisView3D.results properties.
elevationInfo
- Type
- ElevationInfo | null | undefined
Specifies how the geometry's Z values are interpreted, for example to compute elevations for an input profile line. This property can only be used in a SceneView.
origin
- Type
- AnalysisOriginWebScene | null | undefined
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.
profiles
The collection of profile lines to compute and display. Each profile line defines a different source for sampling elevation along the input geometry (such as ground, input geometry itself, custom elevation sources, or scene content), and includes settings for how the resulting line will appear in charts and in the view.
In a MapView, ElevationProfileLineScene is not supported.
uid
- Type
- string
An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.
viewOptions
Configuration options for visualizing an elevation profile within a view.
Methods
fromJSON
- Signature
-
fromJSON (json: any): any
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | 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
- Signature
-
clear (): void
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Clears the analysis by resetting the geometry and elevationInfo properties.
- Returns
- void
clone
- Signature
-
clone (): this
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
- Signature
-
equals (other: this): boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Compares this analysis with another analysis to determine whether they are equivalent.
toJSON
- Signature
-
toJSON (): any
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.