Also known as visible area and visibility index tools, the Viewshed template in the Transform pane provides visibility analysis templates (listed in the Transform - Tiles: Viewshed topic) to find those portions of a terrain elevation surface that are visible to observers located at given points and given heights at those points.
For videos featuring the Viewshed template, see the Previews in Multiple Windows and Visibility of Towers using a Free Tool videos.
Viewshed operations work with a map that contains at least two layers:
Viewshed operations find what portions of the terrain elevation surface are visible from the observer points. The template provides five different Output options, two of which report results by creating a new drawing, and three of which report results by creating a new image.
Output options that create a vector drawing:
Output options that create a single channel, raster image:
The heights of observers can be taken from a numeric attribute field in the observer points table, or directly from Z geometry values for points (the default). If height values are taken from a numeric field, they can be computed relative to the raster height (on by default) or taken as an absolute height.
Viewshed operations by default calculate visibility as seen from the eye height of the observer at each observer point. If observer points do not have either a Z value or a height field specified, the result will show visibility from an eye height of zero above the surface of the terrain at the location of the observer. Even from a tall hill we see less of the surrounding terrain when lying flat on the ground than standing up, so to get sensible results we should make sure to set the Z value for the height of each observer point. That is easy to do: a note at the end of this topic shows how.
To launch the Viewshed template, with the focus on a raster layer, such as Hills, in the Transform pane choose the Tile field and then double-click the Viewshed template.
Consider the simple case of the Viewshed : visible area from any transform, used with just one observer point, the result of which is shown below.
The map shown above has three layers: a Hills image layer that provides terrain elevation, and an Observers layer that contains a single point. The third layer, Visible area any, is the results drawing created by running the Viewshed template using the visible area from any output option, with settings as shown in the Transform pane illustration at above right. We use a Height field in the Observer drawing's table for the height of each observer.
All locations within the blue area in the Visible Area layer are visible to an observer located at the green dot, and standing at an eye height given by the Height field for the point.
The Observers drawing's table has a Height field for each point that contains a value of 10 for each point. With the Relative Z box checked, that means the observer's eye is 10 units above the height of the terrain at that location. Z values are interpreted as using whatever units are used by the terrain elevation image. The Hills image layer is in a coordinate system that uses meters as a unit of measure, so the value of 10 for the observer point means 10 meters. The Relative Z check box tells the template to compute the height of the observer's eye by adding 10 meters to whatever is the height of the terrain at the observer point's location. The effect is to compute visibility as would be seen by a two meter tall person standing on a platform approximately eight meters in height at that location, such as, perhaps a person standing on the roof terrace of a two story building at that location.
The Visible area any drawing contains an area styled in Deep Sky Blue color that was created by the visible area from any output option. What seems to be many separate area objects is in fact a single, multi-branched area object. We have used the Layers pane to set 50% opacity for the Visible area any drawing layer, so some hill shading relief from the Hills layer below can blend with the area, to provide a better visual effect.
We can compare the visibility area created by the transform, as seen at left, with the location of the observer point in the foothills of the terrain, as seen at right. The illustration at right has the area layer turned off to provide a clearer view of the topography in the immediate vicinity of the observer point.
At first glance, we may be surprised that a tall observer standing on the roof of a two story building can see so little of the surrounding terrain, but then we see why that is the case when a closer look shows the observer point is located within a small valley in the foothills. The larger hill below and to the left of the observer point blocks the view of the observer in that direction. The valley is open to the Northwest, so the observer can see more of the terrain in that direction.
Up one level. Return to the main template list to allow choosing the component or field. Use this button to choose a field that is a different data type from the current field. |
|
<component name> |
Gives the name of the raster image layer in the map that the template is using as a source of terrain elevation data. If the map has other raster image layers, we can change to any other raster image layer in the same map. |
Field |
The name of the tile field on which the template operates. If the raster image has other tile fields providing terrain elevation data, we can choose any other such tile field. |
Channel |
The channel to use for terrain elevation data if the tile field in use has more than one channel. Raster images typically provide terrain elevation data using tiles that have only one channel, channel 0, where each value is a single number that gives the height of the pixel. |
Output |
Choose the output option to use within this template. The Transform pane will automatically configure controls to match the output option selected.
Output options that create a vector drawing:
Output options that create a single channel, raster image:
|
View from |
The drawing layer in the map that contains points giving the location of each observer. |
View from selection only |
Run the transform as if the observer points drawing contains only selected points, ignoring points that are not selected. |
Z |
Choose either Geometry Z to use the Z value within the geometry of a point, or choose a numeric field in the observer points table that gives the height of each point. There are two ways to specify the height of an observer above the terrain elevation. Observer points may optionally be XYZ points, where the Z value is used as an absolute height. Another way to specify the observer's height above the terrain is to use the value in a numeric field for each observer. When a numeric field is used, the height value in that field can be treated either as absolute height or as a relative height above the surface at that location. If an observer point does not have a Z value, then a Z value of 0 is used for the point. |
Relative Z |
Appears when a field is chosen to specify Z values. If checked, add the Z value given within the field to the height of the terrain at that location to get the eye height of the observer. This is the default, where the value within the specified Z field gives the eye height for the observer relative to the terrain.
Unchecking this box means that the value within each Z field gives the absolute height of the observer. This can be useful to compute visibility from a drone hovering at a given altitude above sea level where we do not know how high the drone is above the terrain at that location. |
Use datum curvature |
If not checked, use a flat Earth. If checked, reckon the curvature of the Earth as given by the datum in use when computing visibility. Earth curvature can cause effects of about two meters in height at a distance of five kilometers. |
Refraction |
The refraction coefficient of visible light in air, which causes slight bending of light and thus can effect what is visible at various distances. May be adjusted to account for different atmospheric conditions, as the refraction of light in air varies dramatically based on altitude and air temperature. The default value of 0.13 is a frequently-used Gaussian refraction coefficient, the same as used in ESRI viewshed tools, although some studies have indicated this value is not suited for describing refraction effects in the lower atmosphere. If desired, change the value to 0 for no refraction. |
Minimum angle |
The minimum vertical angle for viewing, in degrees from -90 to 90. The default of -90 means to compute visibility for all sight angles all the way down to straight down. |
Maximum angle |
The maximum vertical angle for viewing, in degrees from -90 to 90. The default of 90 means to compute visibility for all sight angles all the way up to straight up. |
Radius |
The radial distance within which visibility will be computed. The default value of 0 means no limit, computing visibility to the full extents of the terrain elevation image. If the Unit specified is meters, setting Radius to 10000 would compute visibility from each observer point out to a radius of ten kilometers, ignoring terrain elevation that is farther away for visibility calculations from that point. Radius is handy to use when visibility within a restricted radius within a very large terrain elevation image is of interest. |
Unit |
Units of measure used to specify Radius. The pull down menu offers a very long list of all linear units of measurement known to Manifold, with Meter appearing by default. |
Result |
Specify the destination for the result of the transform.
When the template creates a drawing, there is only one choice, New Table, since a new drawing must be created. When the template creates an image, there are four choices for saving the raster image created by the template:
|
Result type |
Appears when the template creates a vector drawing. The geometry type to use, Manifold's native geom type, geommfd type, or geomWKB type. Use the native geom type. |
Channel type |
Appears when the template creates a raster image. The numeric channel type to use for Tiles. |
New drawing |
Appears when the template creates a vector drawing. Automatically creates a new drawing of the specified name that uses the resulting geometry field. |
New image |
Appears when the template creates a raster image, either as a new component or by adding a new tile field to the source raster. Automatically creates a new image of the specified name that uses the resulting tile field. |
New table |
Appears when the template creates a new drawing or image. The name to use for the new table. |
Resources |
A choice of CPU and GPU parallelization resources the system is allowed to use:
CPU "cores" are used in the Windows meaning of the word core, meaning hyperthread for CPUs that support hyperthreading when hyperthreading is turned on in the BIOS. Since most modern CPUs and systems support hyperthreading, when Windows reports the number of cores it is really reporting the number of threads. GPU cores are either used fully parallel for all cores or GPU is not used at all.
The Resources setting puts limits on what the system is allowed to use. It does not force parallelization if that would result in slower operation. |
Transform |
Apply the transform template. |
Preview |
Show a preview in blue preview color of what the transform operation will do. A preview is just a temporary view and does not change anything.
Press the Preview button to launch a preview, or to update a preview after changing any parameters or controls in the pane. A preview will stay in view until we hide it, or until a layer used to compute the preview is removed or refreshed. We can add layers, pan and zoom, alt-click objects to view attributes, and edit layers without losing the preview.
Closing a preview: In map windows, right-click the blue preview caption bar at the top of the window and choose Hide Preview. In table windows, right-click the blue preview column head and choose Hide Preview. |
Edit Query |
Launch a Command Window loaded with the SQL query that performs this transform with given settings. |
Pressing the Preview button launches a visual preview of what the Viewshed template will do.
Pressing the Preview button shows the previewed results of the operation using blue preview colors along with a blue preview caption bar at the top of the window with the name of the template used for the preview. Previews are shown on top of all map layers. To close the preview, right-click on the caption bar and choose Hide Preview.
Previews will persist and will continue to be shown through routine operations using other commands and panes. For example, we can pan and zoom into a different location and the preview will still be shown.
We can add layers, like the Bing Streets layer above, and turn off other layers, and the preview will still be shown.
In the illustration above, we have added a Bing satellite layer. Note that the preview still appears even though the Hills layer from which the preview was computed is hidden.
If we would like to compare the preview with a display without a preview, we can right-click the blue caption bar and then choose either Left or Right to show the preview only for the left or the right half of the screen, and then we can drag the blue vertical dividing line between preview and no preview to the left or right as desired.
Another way to see layers below the preview is to right-click onto the preview caption bar and to choose partial opacity, for 75%, 50%, or 25% opacity.
50% opacity allows part of the layer below to show through the preview. As can be seen above, the effect can be combined with left or right split screen. To make the preview layer fully opaque, choose 100% opacity.
We can turn layers off and on and the split screen preview display will remain. We can also temporarily toggle the preview off and on by clicking the preview caption bar.
By default, viewshed operations will calculate visibility through all vertical angles of view, looking all the way down and all the way up, which is what the -90 to 90 range for Minimum angle to Maximum angle means.
If we like we can specify a narrower, vertical range of view. For example, suppose we are planning a line-of-sight microwave radio link where the antennas we use can maintain line-of-sight contact only within a vertical range of plus or minus fifteen degrees. In that case, we could specify a Minimum angle of -15 and a Maximum angle of 15. That will restrict the visibility transforms to only those regions visible from observer points when observers can "look down" no more than fifteen degrees below horizontal, or can "look up" to no more than fifteen degrees above horizontal.
Restricting calculations to vertical viewing angles down and up is also useful for applications such as siting radar installations, where the radar scanner can only tilt down or up so far to scan terrain, or for locating camera or telescope optics for surveillance that can only depress or elevate within given limits, or for positioning weapons systems that can only depress so far to fire below horizontal or elevate only so far to fire above horizontal.
So long as the Minimum angle is less than the Maximum angle, both angles can be negative or both positive.
Given a map with an image providing terrain elevation, a drawing with one or more points indicating the locations of observers, and the parameters specified, these output operations create a drawing with an area that covers those parts of the image that are visible either to all of the observers or to any of the observers. The two operations are equivalent in the case of only one observer point.
The visible area from any output option computes the region visible from any observer. If we have more than one observer and any one or more of those observers can see a particular location, it is part of the region. This is useful for applications such as siting surveillance radars or observation posts, to see the region in view of at least one of the observation posts.
The illustrations above show a drawing with two observer points, both of which have a Height field value of 10, indicating the observer's point of view is ten meters (about 33 feet) above the terrain surface. Using the visible area from any output operation will create a new drawing with an area, seen in purple color above, that shows all regions of the terrain that can be seen by either of the two observers.
The visible area from all output option computes the region visible from all observers. If we have more than one observer and all of those observers can see a particular location, it is part of the region. This is useful for applications such as siting central monitoring stations that must acquire data from multiple sensors using line-of-sight communications. For example, if we have ten seismic sensors on a mountain slope and we want to find a location for a central receiver that has line-of-sight communications to all ten of those sensors, the visible area from all option will find regions where we can place the central receiver.
The illustrations above show a drawing with two observer points, both of which have a Z value of 10, indicating the point of view is ten meters (about 33 feet) above the terrain surface. Using the visible area from all output operation will create a new drawing with an area, seen in green color above, that shows all regions of the terrain that can be seen by both of the two observers.
Because of ridges between the two observers, which tend to block the view of one observer in the regions mostly seen by the other observer, the area of common visibility is mostly down in the low lands below the foothills where the two observers are located. The common area of visibility shows characteristic straight line sides where the view of one observer goes through a valley between ridges that block the view on either side.
To see how the visible area from all area is constructed, we can consider the visible areas for each of the two observers separately. We can select first the upper point, running the transform with the View from selection only box checked, and then we can select only the lower point, running the transform again.
The illustration at above left shows the visible area for only the upper observer. The area is styled with blue color. The illustration at above right shows the visible area for only the lower observer. The area is styled with yellow color. In both of the above illustrations the Hills layer has only 50% opacity, to provide fainter colors against the white background, so the blue and yellow areas are more visible.
The illustration at above left shows both visible area layers, with both using 50% opacity in the Layers pane, so the area of overlap is clearly visible in green color, the result of mixing blue and yellow color in the region of overlap. Comparing that to the result of the visible area from all operation using both points shows us how the visible area from all transform calculates the region that can be seen by both observers.
We can compare the result to that of the visible area from any transform result shown below.
The illustration at left shows the visible areas for the upper observer and the lower observers both styled in the same purple color, using 80% opacity, to make it easier to see the combined effect of both areas. The illustration at right above shows the result for the visible area from any transform, using the same opacity. Combining the regions visible to either the upper observer or to the lower observer generates the visible area from any transform result.
The Radius parameter allows us to set the outer limit for which visibility will be computed for each observer point.
Setting the Radius is useful in many settings. For example, if we have a very large image and we are only interested in a local region within a given distance of observer points, we can use Radius to limit the calculation to only that region, speeding up computation. Manifold is very fast computing visibility even with large image, but even so a calculation on a smaller region will go even more quickly.
Radius is also useful for analytics. For example, suppose atmospheric conditions are often dusty or foggy, limiting the range of view. We can set a Radius number when choosing locations for observation posts to ensure good surveillance coverage even in poor weather. We may have a limit on the range of our equipment: wireless communications bridges may be limited to only ten or twenty kilometers line-of-sight range, or weapons systems that are to be sited may have a limited range or may drop off to unacceptable accuracy beyond a given distance.
In the illustration at left above we have drawn dotted circles at a radius of 6000 meters centered on each observer point. These do not participate in the analysis in any way: they are drawn in the illustration to provide a visual guide to help understand how the Radius parameter works. We have also added layers for visibility without any Radius restriction for each of the two observer points, so we can see the contribution to visibility from each observer point when using the visible from any operation.
In the illustration at right above, we see in purple color the result of the visible from any operation with Radius set to 6000 meters. The calculation for each observer point is limited to only those portions of the Hills terrain within 6000 meters of each point.
Another way to see the effect of Radius is to press the Preview button. The preview will be drawn above all other layers. In the illustration above, we have right-clicked the preview caption bar and have chosen Left to choose a split display with the preview on the left side of the window. We then dragged the blue, vertical splitter line to near the observer points. That allows us to see the effect of the preview while also keeping the observer points in sight.
We can repeat the transform using the visible from all operation, also with Radius set to 6000 meters:
In the illustration at right above, we see in green color the result of the visible from all operation with Radius set to 6000 meters. The calculation for each observer point is limited to only those portions of the Hills terrain within 6000 meters of each point. The result is only those regions of overlap that fall within both circles of 6000 meter radius.
We can also see what would be the result of the visible area from all option with a Radius of 6000 is by pressing Preview, to get the display seen above.
The visible area from any and visible area from any output options create results in the form of a vector drawing. Output options that create a single channel, raster image:
Given a map with an image providing terrain elevation, a drawing with one or more points indicating the locations of observers, and the parameters specified, the visible level from... operations create a single channel image covering the entire terrain image, with the value in each pixel giving a relative height number, called a level for that pixel. Such relative height numbers are also called a visibility index. The level is a positive value if a pixel is visible, and a negative value if it is not visible. Positive height numbers convey how much height the pixel has to spare before it becomes invisible, and negative height numbers convey how much height must be added to the pixel at that location before it becomes visible.
Positive height levels report how far above the threshold of visibility that pixel is located. They report how much height the pixel has to spare before it is no longer visible. For example, a pixel with a level value of 25 would be visible, and it would be 25 units above the level at which it would no longer be visible. If the pixel is located at the top of a small hill, and we cut away the hill to lower the terrain by 25 units, that location would no longer be visible.
Negative height levels report how far below the threshold of visibility that pixel is located. They report how much height must be added to the pixel at that location to make it visible. For example, a pixel with a visibility index of -50 would not be visible, and it would have to be raised at least 50 units to become visible. A line-of-sight antenna at a pixel location with a visibility index of -50 would not be visible, but if it were raised up on a mast at least 50 units high, the antenna would become visible.
Because the result of visible level from... operations is an image, the Result destination can be the same tile field used as the source, an existing tile field in the source table, a new tile field created in the source table along with a new image to visualize that new tile field, or a new table, that is a new image and table. In these examples we will use a new table.
When creating a new image, to be useful it must be styled sensibly. See the various Style topics and examples to learn how to use the Style dialog with images.
The visible level from all operation creates a single channel, raster image where the value of each pixel in the result image reports the visibility level of that pixel for all observer points.
The illustrations above show a drawing with one observer point, which has a Height field containing a value of 10. Using the Height field provides a Z value of 10, and checking the Relative Z box indicates the point of view is ten meters (about 33 feet) above the terrain surface. Using the visible level from all operation will create a new, single channel image covering the entire terrain, with a height level number in each pixel. We choose New Table for the Result, and enter Visible level all as the name for the new image, with an analogous name for the new image's table.
Press Transform.
A new Visible level all image and table appear in the Project pane. We drag and drop the new Visible level all image into the map.
The image appears using default styling. We can style it to provide a more useful display.
In the Style dialog we choose Channel 0 as the sole controlling channel. We choose 10 breaks, press Tally and then apply the Color Brewer spectral palette. We specify transparent color for the last interval, which we adjust to a value of 2. Press Update Style to apply to the image, to create the result seen at left, above.
That is a cool image, for sure. It shows regions that are visible in transparent color, so the terrain layer below can be seen. It colors the rest of the Visible level all image layer with a range of colors, depending on how high the terrain must be lifted at a given pixel to become visible. Deep reds indicate the terrain at that location is over 400 units below the level needed to become visible: such regions are deep valleys hidden from the observer by high ridges.
To see the relationship between the terrain and the height levels reported, we can use the Layers pane to set the Visible level all layer to 50% opacity, allowing the colors in that layer to blend with the hill shaded terrain underneath.
The interval styling shown above, however, does not give a precise visual picture of visibility, because it uses the interpolate method. The last two intervals, where the boundary between not visible and visible occurs, cause a smooth blend of transparency between the blue color and fully transparent, where the exact transition is difficult to see between a location that is visible to the observer and one that is not visible.
We can achieve a sharp-edged boundary between not visible and visible using a different interval style, and restoring the layer opacity for the Visible level all layer back to 100%:
In the illustrations above we have set the last interval value to 0, and have given the next to last interval a value of -1 with blue color. The Fill method is closest lower value. All pixels with level values equal to or above 0 (meaning they are visible to the observer) will therefore be rendered in transparent color, while those less than 0 will be rendered with opaque color, in a range of colors depending on how much they would have to be lifted to become visible.
We can compare that raster image result with the result of the visible area from any operation or the visible area from all operation (both operations produce the same result with a single observer point), as seen at right.
Showing both layers together in the map, we can see how the result a visible area from all operation creates a drawing with areas where the visible level from all operation created regions of pixels with zero or greater values, that is, visible pixels.
The visible area from... operations produce an area that shows terrain visible to the observer point, but they provide no information on how close to or how far from visibility various locations in the terrain may be. The visible level from... operations, in contrast, cover the terrain with a new raster image that provides visibility information for each pixel, showing the regions where the terrain is visible or not visible to the observer, and also showing how close to or how far from visibility the height of each pixel may be.
In the above examples, we have styled the visible level all image so that all pixels with a visibility index value above zero are transparent. If we wanted to see not only those pixels that are visible to the observer but also how visible they are, we could have used an intervals list in the Style dialog that used different colors for different levels of positive visibility index. That would show within the visible pixels region how much a pixel would have to be lowered before it became invisible.
The visible level from... operations also provide a way of creating visual impact assessment analyses that must incorporate viewer heights, for example, when doing wind energy development analysis.
Viewsheds as discussed in this topic take the location and height of observers and show the region of terrain visible to those observers. One way to do a visual impact assessment to find the visibility of, say, wind turbines, would be to use the location and height of the wind turbines as observer points. If somebody standing on the top of a wind turbine can see a particular patch of ground, then to a reasonable first approximation somebody standing on that patch of ground could also see the wind turbine.
However, that first approximation might not be sufficiently accurate if we know the heights of the wind turbines but we do not know the heights of possible viewers who are located in the study area. For example, suppose the study area includes buildings which are 20 meters high: which turbines might be visible to somebody standing on the top of such 20 meter high buildings?
The visible level from... operations provide the answer when we calculate a visibility index viewshed raster using the locations and heights of the wind turbines as observer points. Suppose we assume the average person who might be viewing a turbine is 1.5 meters tall. Any pixels in the visibility raster that have a positive visibility index equal to or greater than 1.5 will enable a viewer standing at that pixel to see a wind turbine. Any pixels in the visibility raster that have a visibility index between -21.5 and 1.5 will enable a viewer standing on top of a 20 meter building (20 meters plus the 1.5 meter height of the person) also to see a wind turbine. Pixels in the visibility raster that have a visibility index less than -21.5 will not enable a viewer standing on top of a 20 meter building to see a wind turbine.
One way to present results in a useful visual impact assessment would be to create the visibility raster using the desired visible level from... operation, and to then color that raster using smoothly interpolated colors or quantized colors for a contour effect to show where viewers standing at various heights of interest could see the structures used as observer points.
The visible level from any operation creates a single channel, raster image where the value of each pixel in the result image reports the visibility level of that pixel for any observer point.
As with the visible area from... operations, the visible level from all or any operations produce the same result with only one observer point. In the illustrations above we use two observer points to better show how the visible level from any transform works.
The illustrations above show a drawing with two observer points, both of which have a Height field containing a value of 10. Using the Height field provides a Z value of 10, and checking the Relative Z box indicates the point of view is ten meters (about 33 feet) above the terrain surface. Using the visible level from any operation will create a new, single channel image covering the entire terrain, with a height level number in each pixel. We choose New Table for the Result, and enter Visible level any as the name for the new image, with an analogous name for the new image's table.
Press Transform.
A new Visible level any image and table appear in the Project pane. We drag and drop the new Visible level any image into the map.
In the illustrations above, we have gone directly to a Style that provides a sharp edge transition between visible regions and those not visible to either of the observer points. Those pixels with a positive visibility level number are rendered using transparent color, so the background terrain can be seen. Those regions that are not visible to either of the two observer points are colored by how much they have to be raised to be visible to one of the observer points.
We can use the Layers pane to apply 50% opacity to the Visible level any image layer, and also to the Hills layer, so the colors in the layer blend with the hill shaded terrain. Comparing that to the result of running the Visible area any operation on the same two points, we can see how the raster equivalent provides additional information beyond the shape of the visible region. The raster also shows how much each pixel that is not visible must be raised to become visible.
The visible count operation creates a single channel, raster image where the value of each pixel in the result image reports the number of observer points from which this pixel is visible.
The illustrations above show a drawing with six observer points, all of which have a Height field containing a value of 10. Using the Height field provides a Z value of 10, and checking the Relative Z box indicates the point of view is ten meters (about 33 feet) above the terrain surface. Using the visible count operation will create a new, single channel image covering the entire terrain, where the value of each pixel in the result image reports the number of observer points from which this pixel is visible. We choose New Table for the Result, and enter Visible count as the name for the new image, with an analogous name for the new image's table.
Press Transform.
A new Visible count image and table appear in the Project pane. We drag and drop the new Visible count image into the map.
We Style the new Visible count image using the settings shown at above, right. We use the unique values method: the value of each pixel must be a whole number from zero to six, since those are the only possibilities for the number of observers that might be able to see a given pixel location. There are no locations that can be seen by all six observers, so the tally of unique values runs only from 0 to 5, inclusive. There are many pixels, colored in red, that cannot be seen by any of the observers. Very few pixels, colored in blue, can be seen by five observers.
Using the Layers pane, we apply 50% opacity to the Visible count image layer, allowing the hill shaded terrain layer beneath to blend visually with the visibility index layer.
We can use the Viewshed SQL Functions to compute visible areas and visibility using queries.
We will use the Hills image and Observers drawing, with three observer points, as seen above. All of the observer points have a Height value of 10. We will compute the area visible from any of the three points, using the TileViewshedAreaAnyPar SQL Function.
The TileViewshedAreaAnyPar function creates an area geom for the area that shows visibility from any of the observer points. We could write a query that first created a drawing and then populated the geometry field in that drawing using the geom created by the function. In this example we will take a simpler approach, first creating a drawing using the File - Create - New Drawing dialog, and then writing a query that uses the TileViewshedAreaAnyPar function to populate the drawing with an area geom. That will be a smaller, easier to understand query without any of the extra salad dressing involved in first creating a drawing.
Before we create the drawing, we will take a moment to save as a Favorite Coordinate System the coordinate system used by the Hills image. For the Viewshed SQL functions to work, the drawings or images that receive the results of the functions must have exactly the same coordinate system as the image on which viewshed or visibility calculations are performed.
With the focus on the Hills layer in the map, in the Component pane we click the coordinate picker button, choose Repair Coordinate System and then Favorites to launch the Favorites dialog. (We do not need to "repair" anything, but that is the quickest way through the dialogs to a menu that lists the Favorites choice.)
The Universal Transverse Mercator coordinate system used by the Hills layer appears automatically in the lower pane.
We Ctrl-click the coordinate system to select it, and then we press Add to Favorites to add it to the Favorites list.
This step not illustrated: When the new favorite appears in the list, we double-click into the keep metrics cell for that entry and we choose override metrics instead.
That guarantee that the new favorite, when used, will apply exactly all coordinate system parameters as used by the Hills image, including metrics such as local scale factors. Press OK. We now have a new favorite coordinate system that will appear in the favorites list whenever we want to specify a coordinate system.
We choose File - Create - New Drawing to create a new drawing called Visible Area From Any. In the New Drawing dialog, we click the coordinate picker button and choose our new favorite Universal Transverse Mercator - Zone 10 (N) # coordinate system from the list. The # in the name indicates that favorite overrides metrics.
Next, we create a query with the following text:
VALUE @threads VARCHAR = ThreadConfig(SystemCpuCount());
VALUE @vsheds TABLE = CALL TileViewshedMakePar([Hills], 0, 0.13, false, @threads);
INSERT INTO [Visible Area From Any] ([Geom])
VALUES (TileViewshedAreaAnyPar(@vsheds, [Observers], 'Height', true, 0, -90, 90, @threads));
We might be working with a larger terrain, so we use the parallel Par versions of the functions. Parallel versions take a configuration parameter specifying the number of threads to use. We will use all CPU threads available, which we get using
ThreadConfig(SystemCpuCount())
calling SystemCpuCount within the ThreadConfig function that returns a JSON configuration string. We could write the above inline as a function argument within any parallel function we use, but it is cleaner to use VALUE to declare a variable, in this case called @threads, that we can later use as a function argument.
Computing the area visible from any observer point is a two-step process: we first create a viewsheds buffer, a table, using the TileViewshedMakePar function, and then we use that viewsheds buffer within the TileViewshedAreaAnyPar function. The templates for those functions are:
TileViewshedMakePar(<image>, <channel>, <refraction>, <useDatumCurvature>, <config>): <viewsheds>
TileViewshedAreaAnyPar(<viewsheds>, <drawing>, <fieldZ>, <relativeZ>, <radiusMax>, <angleMin>, <angleMax>, <config>): <geom>
The two VALUE statements load our @threads and @vsheds variables with the number of threads available and with a viewsheds buffer computed for the Hills image. We then use those within an INSERT INTO statement that loads the Visible Area From Any drawing with area geometry computed by the TileViewshedAreaAnyPar function:
INSERT INTO [Visible Area From Any] ([Geom])
VALUES (TileViewshedAreaAnyPar(@vsheds, [Observers], 'Height', true, 0, -90, 90, @threads));
Running the query, the previously empty Visible Area From Any drawing becomes populated with a single record, which contains a multi-branched area object showing the regions visible within the Hills drawing to any of the three points in the Observers drawing.
We drag and drop the Visible Area From Any drawing into the map, Style it with a contrasting color for the area, and apply 60% opacity in the Layers pane. The result shows all regions that are visible from any of the three observer points.
For more examples using SQL to compute visible area or visibility index, set up any of the transform templates as shown earlier in this topic and press the Edit Query button: Manifold will open a Command Window loaded with the SQL that implements that template, using the specified parameters.
The Viewshed template takes the Z value of each point either from a specified field or from whatever Z value is embedded into the geometry of the point, within the geom field. It is easy to set whatever Z value we want for a point.
Suppose we would like to specify the Z value for each point based on the contents of a Height field, as seen in the table above.
With the focus on the table, in the Transform pane we choose the Geom field as the target, and we double-click the Clean template to launch it in the Transform pane. In the Clean template we choose fill z as the Operation, and then in the Value parameter we choose the Height field. We leave the Result destination to (same field), since we will be updating the Geom field in place by adding a Z value.
We can then press Transform and, for each record, the value in the Height field will be loaded as the Z value into the Geom geometry field. Done.
Sample image - Many illustrations for transforms for raster images use an Elevation Raster sample image, or a variation of that image like the Hills raster image, a version of the formatted example of importing an SDTS format DEM from the Example: Import DDF SDTS DEM Raster File topic. The example project may be downloaded from the Downloads page on the Manifold web site.
Visibility of Towers using a Free Tool