In the ArcGIS Maps SDK for JavaScript
Below is a list of analyses available in the SDK.
| Class | Typical input | Example usage |
|---|---|---|
| 2D only | ||
| DistanceMeasurementAnalysis | Start and end points | Measuring distance between locations on a map, such as stops, landmarks, or parcels |
| 2D and 3D | ||
| AreaMeasurementAnalysis | Polygon geometry | Measuring area and perimeter of selected polygons such as parcels for planning, comparison, or reporting |
| ElevationProfileAnalysis | Polyline geometry or an existing feature | Comparing ground and layer elevation profiles along a line, such as a route or corridor |
| 3D only | ||
| DirectLineMeasurementAnalysis | Start and end points | Measuring distance between locations in a scene, such as assets or design points |
| DimensionAnalysis | Start and end points for one or more dimensions | Creating and displaying measurement annotations for lengths and distances in a scene, such as during design review |
| LineOfSightAnalysis | Observer and one or more targets | Computing the line of sight from one observer to one or more targets, such as from a tower to surrounding buildings |
| ShadowCastAnalysis | Time and location in a scene | Evaluating shadow or sunlight duration around a proposed building, project area, or neighboring structures |
| SliceAnalysis | Slice plane geometry | Creating a slice plane to cut through 3D features and inspect interior content, such as a building interior |
| ViewshedAnalysis | Observer point, direction, and field of view | Evaluating what is visible from an observer location, such as a camera, lookout, or tower |
| VolumeMeasurementAnalysis | Polygon geometry on supported surfaces | Calculating and visualizing cut-and-fill or stockpile volume for a polygonal area, such as an excavation or stockpile |
Analysis objects, analysis views, and analysis layers
Analysis objects are classes that you create and manage in code to build precise interactive measurements, visibility studies, profiles, and other spatial workflows. You typically add them to the analyses collection of a Map or the analyses collection of a Scene, and for some 3D workflows you can also manage them as analysis layers.
const mapComponent = document.querySelector("arcgis-map");const analysis = new ElevationProfileAnalysis({ geometry: { type: "polyline", spatialReference: { wkid: 4326 }, paths: [[[-122.68, 45.53], [-122.58, 45.55], [-122.48, 45.5]]], },});
mapComponent.analyses.add(analysis);An analysis view is the view-specific representation of that object. Obtain it from the map or scene when you need interactive placement, editing, or access to the results of the analysis.
const analysisView = await mapComponent.whenAnalysisView(analysis);Some analyses can be driven directly by input geometry, while others are configured through observer, target, time, direction, field-of-view, or other analysis-specific properties. For example, AreaMeasurementAnalysis uses a polygon, ElevationProfileAnalysis uses a line or feature, and VolumeMeasurementAnalysis uses a polygon area on supported surfaces.
When you need the workflow to persist in a WebScene, appear in a layer list, or behave like other scene content, some analysis workflows can be managed as layers in a 3D scene.
ViewshedLayerstores aViewshedAnalysisin itssource.DimensionLayerstores aDimensionAnalysisin itssource.LineOfSightLayerstores aLineOfSightAnalysisin itsanalysis.
This lets you move supported workflows between the scene’s analyses collection and layer-based management as your application’s needs change.
The analysis lifecycle
Most analysis workflows follow the same pattern:
- Create an analysis object.
- Add it to the map or scene.
- Obtain the corresponding analysis view.
- Optionally place or edit it interactively.
- Update its properties or clear it when the workflow changes.
The following code creates a ViewshedAnalysis, creates a Viewshed, adds the viewshed to the analysis, and then adds the analysis to the scene component.
const sceneComponent = document.querySelector("arcgis-scene");const analysis = new ViewshedAnalysis();const viewshed = new Viewshed({ observer: { spatialReference: SpatialReference.WebMercator, x: -9754426, y: 5143111, z: 330, }, farDistance: 900, tilt: 84, heading: 63, horizontalFieldOfView: 85, verticalFieldOfView: 60,});
analysis.viewsheds.add(viewshed);
sceneComponent.analyses.add(analysis);Analysis views support interactive placement with the place() method, which starts an interactive placement workflow for the current analysis view. Use this when you want to build your own toolbar, guided workflow, or analysis-specific UI.
const analysisView = await sceneComponent.whenAnalysisView(analysis);const abortController = new AbortController();
try { await analysisView.place({ signal: abortController.signal });} catch (error) { if (error.name !== "AbortError") { throw error; }}This method is not yet supported for ShadowCastAnalysisView3D.
Because analyses expose properties and collections, they can be updated directly in response to user input or other events, and reset when needed with clear().
selectedViewshed.horizontalFieldOfView = 90;selectedViewshed.verticalFieldOfView = 60;
if (resetAnalysis) { analysis.clear();}This method is not yet supported for ShadowCastAnalysis.
Analyses, geometry operators, and spatial analysis
Now that you have seen what analyses do in the SDK, it is useful to distinguish them from geometry operators and spatial analysis, which solve different kinds of problems.
Use geometry operators when you need a direct client-side calculation on one or more geometries and want the returned value immediately, without creating an analysis that remains in the view.
Use spatial analysis when you are looking for analytical workflows based on operators, calculations, or analysis services rather than classes that are managed directly in the map or scene.
Related tutorials and samples
Learn more about the analysis lifecycle in the Create and manage a viewshed analysis tutorial, or see the full set of analysis samples.