import Viewshed from "@arcgis/core/analysis/Viewshed.js";const Viewshed = await $arcgis.import("@arcgis/core/analysis/Viewshed.js");- Inheritance:
- Viewshed→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Viewshed defines the geometry for a viewshed analysis. The viewshed is determined by a position, distance, orientation (defined by heading and tilt), and field of view angles.
const viewshed = new Viewshed({ observer: new Point({ spatialReference: { latestWkid: 3857, wkid: 102100 }, x: -9754426, y: 5143111, z: 330 }), farDistance: 900, heading: 64, tilt: 84, horizontalFieldOfView: 85, verticalFieldOfView: 52});const viewshedAnalysis = new ViewshedAnalysis({ viewsheds: [viewshed],});
// add the analysis to the viewview.analyses.add(viewshedAnalysis);To create a view dome, set horizontalFieldOfView to 360, and verticalFieldOfView to 180.
Note that when placing viewsheds interactively, the viewshed is created with a 1.5 meter vertical offset from the scene. This behavior is subject to change in a future release.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
valid readonly | | |
| |
farDistance
- Type
- number
The maximum distance from the observer in which to perform the viewshed analysis (in meters).
- Default value
- 1000
feature
- Type
- FeatureReference | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.31
References a feature from which the observer is internally offset, provided that its geometry faces are close enough to the observer. It is used to ensure that the analysis results remain independent of changes in the level of detail (LOD) of this feature's geometry.
When creating viewsheds interactively, this property is populated automatically.
Note that you can assign client side graphics which will be taken into account accordingly. However, information about client side graphics will not be persisted and results in an empty reference after de-serialization.
heading
- Type
- number
The compass heading of the observer's view direction (in degrees). A heading of zero points the viewshed to north and it increases as the viewshed rotates clockwise.
- Default value
- 0
horizontalFieldOfView
- Type
- number
The horizontal field of view (FOV) angle defines the width of the scope being analyzed (in degrees). A value of 360 means the observer's horizontal FOV captures their entire surroundings. Values closer to 0 narrow the horizontal FOV in the direction of the heading.
- Default value
- 45
tilt
- Type
- number
The tilt of the observer's view direction (in degrees). A tilt of zero points the viewshed looking straight down and 90 degrees points it looking parallel to the surface.
- Default value
- 90
valid
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Indicates whether the viewshed is ready to be computed and interacted with in the view. It requires the observer to be set and have a position, and the farDistance to be greater than 0.
verticalFieldOfView
- Type
- number
The vertical field of view (FOV) angle defines the height of the scope being analyzed (in degrees). This value can vary from 0 to 180. Values closer to 0 narrow the vertical FOV in the direction of the tilt.
- Default value
- 45
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.
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.
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.