Home‎ > ‎D) Software‎ > ‎D.A) VBA‎ > ‎

D.8.3) Viewshed

A viewshed is an answer to "what can I see from here?", i.e., anything that can be seen from a given point.

Creation of a viewshed seemed an interesting challenge to undertake.

DTED

Digital Terrain Elevation Data (DTED) is what it says: data that describes the topological properties of the Earth's surface over a given area. The most easily obtain is Shuttle Radar Topography Measurement (SRTM) measured by the Space Shuttle and available as open source material. It is typically available at various resolutions in one degree x one degree blocks. The .hgt files at, for example, www.g7lwt.com do not have any header information in the file and are easiest to use.

The information in the .hgt files is a continuous stream of data. The first 2402 characters describe the first row of 1201 points of constant latitude; the next 2402 the second, etc., until row 1201 is reached. The height information is included as two bytes, e.g. 8 bits. When read as unicode data the height information looks like the example below:


The ASCII value for 'NUL' is zero; the ASCII value for 'x' is 120. The sum of the two is 120 (m AMSL):

Using VBA in Excel it was possible to read the bytes and generate a map of the terrain data, using the conditional formatting of Excel to colour it. Excel doesn't allow zooming to the point where the whole map (1201 columns x 2401 rows) is visible but what is visible Has the sort of detail shown below:


In addition to the river Thames it is possible to see the detail of fields and some roads.

To be visible from an object, O, above the horizon an object, L, of height, hL (ft), must be less than distance d (miles), distance, where:

    d =  3.57 x (hO^0.5 + hL^0.5)

Given a horizon distance, d, in miles, the height, h, in feet required to be visible equals:

    h = d2 / 1.513

This can be used to (more-or-less) correct the height data for the curvature of the earth, i.e., reduce the height of each point by h based upon d.

FOR A RANGE OF ELEVATIONS FROM BELOW THE HORIZON TO ABOVE THE HORIZON
    FOR EVERY CELL, ONE AT A TIME
        SELECT A CELL AT (X,Y)
        TRAVEL BACK IN A (THREE DIMENSIONAL) STRAIGHT LINE TO THE VIEWPOINT
        TAKING INTO ACCOUNT THE CURVATURE OF THE EARTH IS THERE A POINT BETWEEEN THE CELL AND THE VIEWPOINT HIGHER THAN THE HEIGHT OF THE SELECTED CELL?
                IF YES
                    LEAVE THE CELL BLANK
                    STOP REVIEWING THE SELECTED DATA POINT
                ELSE
                    PUT INTO THE CELL THE HEIGHT DATA CORRECTED FOR THE CURVATURE OF THE EARTH
                END IF
    NEXT
NEXT

Between the viewpoint and the furthest visible point the may be sections that are not visible.

By interpolating in three dimensions between the data point (Excel cell) being tested for visibility and the origin it is possible to determine whether there are any obscuring points between the two. 




For a high point in Petworth, West Sussex, the result is as below. I am not sure some of the outlying points are 100 % accurate but it gives a good idea. The green areas are those that are visible - mostly the Weald between the South and North Downs.


(Underlying Map (c) Google)

This is what Google Earth Pro produces as a viewshed (albeit to a limited radius):



Comments