Least Cost Path

Least Cost Path can be used to calculate the least cost past from one point on an orienteering map to another.
There are four different methods to use the functions of least cost path.

All methods need a height grid and a velocity grid as input, as well as a resolution. Further a velocity model and step-directions can be provided. If these values are not given, default values are taken.
Depending on the purpose, various data can be calculated:
Giving a start point and an extent, a time grid and direction grid.
Giving an end point, an invers time grid and invers direction grid.
Combining start and end result, a cost grid and distinct routes.
 

Height grid

Height grid is a double grid.  In the user interfaces of OCourse.exe and LeastCostPathUI.exe it is imported from a standard ESRI ASCII-GRID-File. The georeference of the height grid must correspond to the georeference of the velocity grid.

Velocity grid

Velocity grid is a double grid. In the user interfaces of OCourse.exe and LeastCostPathUI.exe  it is generated from a velocity image. This image should be a georeferenced gray scale image. Such a georeferenced gray scale image can be produced from OCAD with a specific symbol set (see below). Remark : An additional area must be added to the OCAD file, covering the entire map area and being in the background, with a gray value corresponding to the velocity on normal terrain without obstruction. 

The velocity for flat terrain at a point corresponds to the gray value at the image point. Full black means a relativ velocity of 1, white means a velocity of 0. For least cost path calculation, it is sufficient to provide the relativ velocities, because the path is independent from the absolute values. Just if you want to know times along a path, the absolute values become necessary.

 

Cost Model
The cost model defines the actual cost need to get from one cell to a neighboring cell given base velocity (obstruction) from velocity grid, height change in running direction and slope of terrain.
To use a specific velocity model, define a method corresponding to the delegate Grid.StepCostHandler and assign this method to LeastCostPath.StepCost.

OCourse.exe

OCourse.exe is to analyze entire OCAD-Course files.


Setting height model and velocity model is optional. If they are set, a least cost path calculation is performed for the selected course and the results displayed in the datagrid. Information about the currently calculated section is displayed at the bottom of the window.
The fields of the data grid correspond to the chosen course or the current selection in the course window:
-DirectLKm is the air distance along the course + 10x climb.
-DirectKm is the air distance along the course.
-Climb is the climb along the least cost path routes.
-OptimalLKm is the distance along the least cost path routes + 10x climb.
-OptimalKm is the distance along the least cost path routes.
-OptimatC is the cost along the least cost path routes.

Create Scripts generates a batch file for calculating all the cost models. These batch file containes 3 sections:
- calculating all cost and direction models for all controls
- calculating all invers cost and direction models for all controls
- calculating all cost and route models for all sections.
Each line in the section file can be run individually. So parallizing on computers with multiple cpu's can be achieved.
Remark: For the third section, the first two sections must already be performed.
Back Calc performs the least cost calculation for all routes of the entire course file in the background.
Export exports the caluclated routes to a shape file.
Import imports calculated routes from a shape file. If the imported routes correspond to the routes of the course file, the imported routes are used and no calculation is needed.

MouseDown on first control, MouseMove, MouseUp on second control enables a button for detailed analyzing of the the selected section. Pressing the the button opens a similar control as in LeastCostPathUI without Parameters with height model, velocity model, resolution, step, step cost, start point and end point set corresponding to the settings in OCourse.exe.


Selecting a section for route calculation be mouse down on first control (55) and mouse up on second control (37). Clicking on "Calc xx-xx" activates the LeastCostPath user interface.  

LeastCostPathUI.exe with Parameters 
The parameters define all needed data and results to calculate.

LeastCostPathUI.exe without Parameters 
GUI with various options to do route analysis


Least cost path graphical user interface 

Height Grid see above
Velocity Grid see above
Resolution defines the cell size for the resulting grids.
Steps defines the used step model (horizontal and vertical - with diagonals - with knight-distance fields).
Cost defines the
method to calculate the cost to get from one cell to a neighboring cell. It can be either set by selecting a method from an assembly or by providing the text for the calculating method.
Extent defines the calculating area. It should at least include the from (x,y) and to (x,y).
From x, y defines the start point and calculates the cost grid and direction grid from the start point
If activated, "From Cost" exports the corresponding double grid to the specified file. 
If activated, "From Direction" exports the corresponding grid to the specified file.
If activated, "From Cost Image" converts the corresponding double grid to a georeferenced TIF-File.
If activated, "From Dircetion Image" converts the corresponding grid to a georeferenced TIF-File.

To
x, y defines the end point and calculates the invers cost grid and direction grid to the end point.

If activated, "To Cost" exports the corresponding double grid to the specified file. 
If activated, "To Direction" exports the corresponding grid to the specified file.

If activated, "To Cost Image" converts the corresponding double grid to a georeferenced TIF-File.
If activated, "To Dircetion Image" converts the corresponding grid to a georeferenced TIF-File.

Route
If activated, "Route Cost" exports the corresponding double grid to the specified file. 
If activated, "Route Cost Image" converts the corresponding grid to a georeferenced TIF-File.
Max slower and min offset define parameters for distinct routes evaluating. Max slower defines the value that a specific route can be slower than the least cost route to still be a candidate for a distinct route. Min offset multiplicated by the length of the least cost route is the distance a distinct route must be away (at least in one point) from any distinct route with less cost to be accepted as a distinct route. 

If activated, "Route Shape" exports the distinct routes to an ESRI Shapefile with Z and M coordinates. The M coordinates contain the cost at each point. 
If activated, "Route Image" converts the distinct routes to a georeferenced TIF-File.
 

Class LeastCostPath

Double Grid
A double grid is a structure to store regulary spaced double data. To reduce storage usage for large grids, there is a possibility to use smaller datatypes like short, int, ... as base storage. At runtime, they are converted to double values.  
 

Georeferenced Images
Georeferenced images can be imported to OCAD without need to adjust spatially.