Skip to content
import Viewshed from "@arcgis/core/analysis/Viewshed.js";
Inheritance:
ViewshedAccessor
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 view
view.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.

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.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

farDistance

Property
Type
number

The maximum distance from the observer in which to perform the viewshed analysis (in meters).

Default value
1000

feature

Property
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

Property
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

Property
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

observer

autocast Property
Type
Point | null | undefined

A Point specifying the position the viewshed is calculated from.

tilt

Property
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

readonly Property
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

Property
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

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone
inherited
clone(): this
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.

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.

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.