This topic describes the ST_ComputeViewShed function. This function computes the view frustum for a viewpoint of a scene object and retains the geometry that is formed by viewsheds of the viewpoint.
Syntax
meshgeom ST_ComputeViewShed(scene sc, cstring viewpoint);Parameters
Parameter | Description |
sc | The scene object. |
viewpoint | The information about the viewpoint. The value is in the JSON format. |
The following table describes the fields in the JSON value.
Field | Description | Valid values |
x | The x-coordinate of the viewpoint. Default value: 0. | (-inf, +inf) |
y | The y-coordinate of the viewpoint. Default value: 0. | (-inf, +inf) |
z | The z-coordinate of the viewpoint. Default value: 0. | (-inf, +inf) |
h | The height of the viewpoint. Default value: 0. | [0, +inf) |
azimuth | The angle that rotates in the clockwise direction starting from the north (y-axis forward direction) to the viewing point. Default value: 0. Unit: degrees. | [-180, 180] |
pitch | The pitch angle, which indicates the angle between the viewing point and the XOY plane. If the viewing point is above the XOY plane, the pitch angle is positive. Otherwise, the pitch angle is negative. Default value: 0. Unit: degrees. | [-90, 90] |
distance | The maximum viewing distance. A larger value indicates a wider coverage of the view frustum. Default value: 100. | (0, +inf) |
horizontalFov | The horizontal FOV. Default value: 90. Unit: degrees. | (0, 180) |
verticalFov | The vertical FOV. Default value: 60. Unit: degrees. | (0, 180) |
depthMapSize | The size of the depth map. A larger size indicates a finer view frustum. Default value: 128. | (0, 2048] |
Description
This function computes the view frustum for a given viewpoint of a specified scene object and retains the geometry that is formed by viewsheds of the viewpoint. For more information about the view frustum, see ST_ComputeFrustum.
This function supports only scene objects of the osg type.
The following figure shows an example view frustum.
View frustum (top view)

View frustum (side view)

Examples
SELECT ST_NumPatches(ST_ComputeViewShed(scene, '{"x" : 2938, "y" : 750, "z" : 90, "h" : 1.8, "azimuth" : 90, "pitch" : -35, "horizontalFov" : 90, "verticalFov" : 60, "distance" : 600, "depthMapSize" : 128}')) from t;
--------
32766