import ElevationProfileAnalysis from "@arcgis/core/analysis/ElevationProfileAnalysis.js";
const ElevationProfileAnalysis = await $arcgis.import("@arcgis/core/analysis/ElevationProfileAnalysis.js");
@arcgis/core/analysis/ElevationProfileAnalysis
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 view
const analysisView = await view.whenAnalysisView(elevationProfileAnalysis);
// Retrieve the results, once they are ready
reactiveUtils.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 point
abortController.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.
- See also
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
| Name | Type | Summary | Class |
|---|---|---|---|
The name of the class. | Accessor | ||
Unit systems (imperial, metric) or specific units used for computing and displaying elevation profile results. | ElevationProfileAnalysis | ||
Specifies how the geometry's Z values are interpreted, for example to compute elevations for an input profile line. | ElevationProfileAnalysis | ||
The Polyline along which elevation is to be sampled. | ElevationProfileAnalysis | ||
A user settable identifier for the analysis. | Analysis | ||
The origin of the analysis. | Analysis | ||
The collection of profile lines to compute and display. | ElevationProfileAnalysis | ||
The analysis type. | ElevationProfileAnalysis | ||
An automatically generated unique identifier assigned to the instance. | Analysis | ||
Indicates whether the analysis is ready to be computed and interacted with in the view. | ElevationProfileAnalysis | ||
Configuration options for visualizing an elevation profile within a view. | ElevationProfileAnalysis |
Property Details
-
displayUnits
PropertydisplayUnits ElevationProfileDisplayUnitsautocast -
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
PropertyelevationInfo ElevationInfo |null |undefinedautocast -
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.
-
The Polyline along which elevation is to be sampled.
-
origin
InheritedPropertyorigin AnalysisOriginWebScene |null |undefinedautocastInherited from Analysis -
The origin of the analysis. The origin can be of type
web-scenewhen the analysis was applied from the WebScene.initialViewProperties or a Slide.
-
profiles
Propertyprofiles Collection<(ElevationProfileLineGround|ElevationProfileLineInput|ElevationProfileLineQuery|ElevationProfileLineScene)>autocast -
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.
-
type
Propertytype Stringreadonly -
The analysis type.
For ElevationProfileAnalysis the type is always "elevation-profile".
-
viewOptions
PropertyviewOptions ElevationProfileViewOptionsautocast -
Configuration options for visualizing an elevation profile within a view.
Method Overview
| Name | Return Type | Summary | Class |
|---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
this | Creates a deep clone of this object. | Analysis | |
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor |
Method Details
-
Inherited from Accessor
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Inherited from Analysis
-
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.
ReturnsType Description this A deep clone of the class instance that invoked this method.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}Inherited from Accessor -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns trueif a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");