Sunteți pe pagina 1din 14

A direction dependent least cost path algorithm for roads and canals(*)

Walter Collischonn1 and Jorge Victor Pilar2

Abstract In planning potential routes for roads and canals, topography often acts as a significant constraint. From the almost infinite trajectories that are possible between two points, the selected path should be a good approximation of the one with the least cost, and it should avoid exaggerated slopes. In the case of a canal, uphill reaches of the path should be restricted to a minimum. This paper presents a least-cost-path algorithm developed to find the best path given the topography, the starting and ending points of the linear feature (canal or road) and a function relating slope, distance and cost. The algorithm is based on dynamic programming techniques adapted to solve problems on a grid, or raster structure, that is usually used by Geographical Information Systems. We implemented the algorithm in a computer program and applied it to solve hypothetical problems. Although not real cost functions where used, the results were coherent and showed the capabilities of the algorithm.

(*)

Trabajo a ser publicado en el nmero de junio del 2000 del International Journal of Geographical Information Systems

Instituto de Pesquisas Hidrulicas Universidade Federal do Rio Grande do Sul Porto Alegre RS Brasil e-mail: cllschnn@vortex.ufrgs.br ; Phone: 55 051 316 6325 ; Fax: 55 051 316 6327 2 Escola de Engenharia Universidade Nacional del Nordeste Resistencia Argentina e-mail: jpilar@ing.unne.edu.ar ; Phone: 54 03722 425064

Introduction

The computation of least-cost-paths is, perhaps, one of the most potentially useful applications of geographic information systems (GIS). Finding a minimum path over a surface partitioned into regions of different frictions to movement has two aspects: 1. Creation of an accumulated cost surface from a cost-of-passage surface (where the frictions are stored); and 2. Tracing a slope line down the accumulated cost surface from a departure point to a destination (Douglas, 1994). In a GIS environment the cost-of passage surface is a grid where the values associated to the cells are used as weights for calculating the least-cost-paths. These weights represent the friction or difficulty to cross the cell, and may be cost, time, distance or risk. Integration of an accumulated cost surface from a cost of passage surface requires a spreading function that begins at the previously defined destination of the path. At the start of the procedure only the destination point cell has a defined value of accumulated cost, and the spreading algorithm searches its eight neighbouring cells, stopping on the first one not previously assigned a value. From that one, the algorithm begins another search of its eight neighbours to find the ones with defined values of accumulated cost. For each of them the cost-of-passage of the cell is added, and the smallest of it is recorded as the accumulated cost of the cell. This procedure is repeated until every cell has been assigned a cumulative cost value (Douglas, 1994). Once a cumulative cost surface is crated a new surface can be crated, assigning each cell a number that indicates the least costly direction to the ending point, following slope lines over the cumulative cost surface. This best-direction surface is used to draw the least cost path from the departure point to the destination (Lee and Stucky, 1998). This procedure is an adaptation of algorithms, such as Dijkstas, that are traditionally applied to solve network problems, like the one depicted in figure 1a (Taha, 1996). Using a raster data structure, each cell may be seen as a node linked to its 8 neighbours, and the resulting network over the raster surface is depicted in figure 1b. This network view of a surface has some shortcomings, because to link distant nodes the possible paths are frequently zigzag paths that are longer than a direct link.

Douglas (1995) and Xu and Lathrop (1995) showed the errors produced by this simplification and proposed algorithms to find more realistic least cost paths and spread surfaces. Our concern, however, is over another question, also related to the algorithm. a
5 8 7 11 5 6 7 4 6 9 8 9 5 10 4 5

Figure 1: a) Classical network with weighted links connecting punctual nodes; b) Network consideration of raster data structure with 8 links to and 8 links from each cell.

Network algorithms adapted to raster data structure may be applied to solve the three main problem types showed in figure 2 to 4. The first is the simpler, where costs are related to the node location, but are the same for all directions (figure 2). Douglas (1995) discussed this type of problem, that we will call isotropic. Although many problems of route finding can be solved by the procedure described above (Lee and Stucky, 1998; Weber and Hasenack, 1999), it is limited to situations where the cost of passage or friction is the same for all directions of movement (Stefanakis and Kavouras, 1995). In the second problem type, costs may be related to direction, but this anisotropy has one prevailing direction and is valid for the whole surface. Xu and Lathrop (1995) adapted the algorithm to simulate wildfire spreading influenced by wind direction. Fire spreading in the direction wind blows is naturally faster, and costs related to this direction should be lower (figure 3). Network problems that can be solved by Dijkstras algorithm may be of a third type, where costs of passage are really anisotropic (figure 4). In this type of problem costs are variable over the surface and are direction dependent, but the direction dependency is not in a prevailing direction, but is also variable over the surface.

3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7

7 7 7 7 7 7 7 7

7 7

7 7

Figure 2: Isotropic least cost path problem: the cost of passage is dependent on location only.

3 6 3 3 2 3 6 3 8 2 3 3 6 3 3 2 8 2 3 6 3 8 2 3 2 8 3 6 6

7 14 7 7 4 7 5 7 14 7 7 4 7 5 7 14

7 7 9 4 7 7 9 4 7 7 5

7 5

Figure 3: Partially anisotropic least cost path problem: the cost of passage is dependent on location and direction, but there is one prevailing direction for the whole surface (for example it's easier to go left and up).

We think that potential route planning for structures that are strongly influenced by topography should be analysed by a least cost path algorithm that preserves Dijkstras algorithm capabilities to solve anisotropic problems such as the one in figure 2c. Indeed, there are many problems where the cost of passage is related to the direction, such as road and canal routing, that would be good examples of the third type problem.

At first, such structures as roads and canals are constructed trough routes with limited slope, and slope is dependent on the direction of the route. Roads with slopes exceeding certain limits are difficult to construct, to maintain and to use. Canals have slope restrictions related to maximum flow velocities and have routes that go never uphill, except if additional costs for pumping stations are provided. At second, the cost of construction of such structures may be related to slope. Large irrigation canals, for example, need complex and expensive gates to go along steep reaches. A 100 m reach of canal over a steep reach may need one or more such gates, and will be more costly than a 100 m reach over mild slopes.

22 9 3 2 2 3 6 3 8 8 5 9 4 4 1 2 1 2 1 6 1 5 6 3 4 8 9 7 8

8 19 7 5 4 2 4 12 14 1 24 3 4 5 7 14

7 7 9 8 3 8 6 4 1 7 2

7 1

Figure 4: Full anisotropic least cost path problem: cost of passage is dependent on location and direction.

Unlike the constant anisotropy of waves, wind and burning fire analysed by Xu and Lathrop (1995), which has one prevailing direction and is valid for the whole surface, the anisotropy of travel costs related to slope varies over the surface according to local terrain and travel direction. It is clear that slope may be used as a cost-of-passage variable only as a characteristic of terrain (slope in the direction perpendicular to the contour lines), not dependent upon the direction of travel or flow. A least cost path analysis performed by Jaga et al. (1993) considered areas of steep slope absolute barriers to road passage, by attributing very high values of friction. Slope was considered as an attribute, but the problem was

solved by a isotropic analysis. But, in our understanding, it is as a direction-dependent variable that slope achieves importance. This can be seen often in highway construction, where a sinuous, long, but less inclined path, is preferred over a short and more inclined one. Since the direction of travel for each cell is not defined at the beginning of the best route finding process, the cost-of-passage surface is also not defined, and the traditional least-cost-path finding procedure can not be applied to solve problems with direction dependent costs. An alternative algorithm is presented in this paper, which can be used to draw the best path for a canal or road over a digital elevation model (DEM) representing the topography. The necessary costs to find the best path are related to the direction dependent slope, through a pre-defined function. The algorithm is iterative, to make it possible to solve the problem even when the best path is very complex, such as a spiral.

The algorithm

The algorithm uses a digital elevation model and the points of departure and destination of the path as input data. Accumulated cost is calculated spreading from the departure point to its 8 neighbours, using searching techniques similar to the ones commonly used for identifying characteristics of drainage basins (Jensen and Domingue, 1988). The spreading is iterative and at the k iteration three accumulated cost surfaces are stored: the k iteration surface, which is the most updated; the k-1 and the k-2 iteration surfaces. A window of nine cells (3 x 3) moves over the surface, from the upper left to the lower right, searching for a cell with accumulated cost recently defined or altered (figure 6a). Since the procedure is iterative, recently defined means that at this cell accumulated cost values for iterations k-1 and k-2 are different. The search stops when one of the eight border cells has its accumulated cost value attributed or revised during the last iteration. The recent change of this value is a sign that the central cell accumulated cost value must be either calculated for the first time or revised, since a new path may be created by the change of its neighbour accumulated cost value. Figure 6b shows this step for the first iteration.

If one of the neighbours had its accumulated cost recently altered, the algorithm searches all of the neighbours whose accumulated cost is already defined for iteration k. These neighbours are marked as potential links to the central cell (figure 6c). The accumulated cost for the central cell for paths coming from each of them are calculated and the lower of them is recorded as the new value for the central cell. The chosen direction is also recorded in a best direction surface, for reasons explained next. The accumulated value is calculated summing the accumulated value of the neighbour plus the cost of passage from the central cell to the neighbour. Cost-of-passage from the considered cell to each of the eight neighbour cells is calculated as a function of slope and distance between these cells. Slope is calculated simply as the elevation difference divided by the distance between them. Cost is obtained from a pre-defined cost vs. slope function. Hypothetical forms of these functions are given in figure 5. In the case of canals, a negative slope would represent movement uphill, and should be avoided with a cost penalty.
Cost

Slope

Figure 5: Proposed general forms of cost vs. slope functions for roads (continuous) and canals (dashed).

At the beginning of the first iteration, the only cell having a recently defined accumulated cost is the ending point cell. At the end of each iteration, at the lower right corner, the algorithm verifies if at least one cell has changed its accumulated cost value. In the positive case, the window moves to the upper left corner of the surface and a new

iteration starts. The algorithm stops if no cell has its accumulated cost changed during that iteration. Neither of the cells is considered to have a definitive accumulated cost value until the whole surface is calculated. Each time a cell has its accumulated value revised, because an alternative and cheaper path from it were found, all of its eight neighbours have to be revised in the next iteration, to verify if the new possible paths are better than the last calculated ones. After the accumulated cost spreading, the usual procedure for determining the best path, traversing the accumulated cost surface down to the lowest neighbour (Douglas, 1994) is not applicable in the kind of problem we proposed. A neighbour with low accumulated cost value can be on the top of a mountain from where it is cheaper to get to the destination, but the cost of passage to this neighbour can be more expensive, because of a obstacle such a cliff, than a long path circulating the obstacle. Recording the best direction to follow for each cell in a surface makes the path defining the easier step, since this surface is simply traversed from the initial to the ending point. This could be repeated for any cell considered as the initial point, since the best directions to the end were recorded for all the cells. The structure of the algorithm can be described as follows: 1. Input: 3. Iteration a 3 x 3 cell window moves over the DEM, and the k to k-2 surfaces from the left high to the right down corner; DEM surface; departure and destination points of the path; function relating cost and slope;

2. Initialisation: k, k-1 and k-2 iterations accumulated cost surfaces are created each cell is given a very high value of accumulated cost; at the destination point the k-1 iteration accumulated cost is changed in relation to the k-2 the accumulated cost at the destination point is zero; a best direction code surface is created;

each time one of the border cells of the window have different values for k-1 and k-2 iteration accumulated cost surfaces; select the border cells where the accumulated cost is already defined; for each selected neighbour cell calculate the slope between it and the central cell; for each selected neighbour calculate the cost of passage (CP) from the slope using the slope vs. cost function; for each selected neighbour calculate the accumulated cost for the central cell: AcCost (central cell) = AcCost (neighbour) + CP record the lowest from the calculated accumulated costs to the central cell in the k iteration accumulated cost surface; record the direction that gives the lowest cost in the best direction code surface;

if neither of the cells has neighbours recently changed at the end of the surfaces (right down corner), quit the iteration; else start it again;

4. Output: Follow the directions given by the best direction surface from the departure to the destination of the path, creating the least cost path.

a Destination point

d Moving window

Cells with already defined accumulated cost

Figure 6: a) The moving window start the search; b) the destination point is found, an accumulated cost is calculated for the central cell; c) for the next position two directions are possible the one with least accumulated cost is chosen; d) at the end of the iteration the eight cells around the destination point have defined accumulated costs.

The iterative procedure makes it possible to find out very complex paths, such as spiral ones. We observed that the number of iterations is proportional to the path complexity. As it is, the algorithm is ready to find best paths from a starting point to an ending point, and from a starting point to an ending line or polygon.

Implementation

Two tests were performed with the described algorithm implemented in a computer program: one for a typical irrigation canal routing and another to test the algorithm capability in finding complex and sinuous, but less inclined paths, that could be useful in planning highway routes. The first test was designed to be a hypothetical case of irrigation canal design, where the best route to follow, from a starting to an ending point, over a DEM representing topography, is required. The best route has to be short, has an almost constant slope and should never go uphill. The starting and ending points were located at places intended to turn difficult the route finding. The ending point is in a valley and the starting point is behind a mountain (figure 7). The 60 columns by 70 lines sample DEM was extracted from a 1km x 1km DEM of South America, from an arbitrary region. The cost vs. slope function is hypothetical, similar to the ones shown in figure 1. The result is shown in figure 7, where the darker tones correspond to lower terrain and lighter tones represent higher terrain.

End

Start

Figure 7: Best route of an irrigation canal.

As can be seen in figure 7, the calculated path is sinuous, because it progresses always downhill, almost following the contour lines. Although the shortest path would be a straight line that would go over the elevation between the two points, this path is avoided. Near the ending point the path enters the valley gradually, avoiding big slopes. The elevation is avoided not because high elevations are associated to high costs of passage (they arent), but to travel to the top would be travel uphill, and high costs are associated to uphill movement. The second test was carried over an artificial DEM, generated as a volcanic cone with a distance measuring function of IDRISI (Eastman, 1995). A random surface was generated and overlaid to the original cone, in order to generate a more nature like cone. The random elevations lie between 0 and 5% of the elevations of the cone. A cost vs. slope

function was generated, where the minimum cost related slope was lower than the slope of a straight line linking the starting and ending points. The result is shown in figure 8, where the lighter tones represent high regions. The calculated best route climbs the cone following a spiral path. Before the spiral ends a complete turn, the direction of travel is altered, but the spiral form remains. This test shows the algorithm capability of finding a route with a limited slope to climb a steep mountain. The inflexion of the path, where the direction of the spiral is altered, could be avoided if the cost function incorporates a turning cost or turning penalty, which would be proportional to the change in direction from one cell to another.

Figure 8: Best route of a road up a conical mountain.

Concluding remarks

This paper presents a proposal of a least-cost-path algorithm developed to find the best path given the topography, the starting and ending points of the linear feature (canal or road) and a function relating slope, distance and cost. As long as we know no similar algorithm is implemented in commercially available GIS software, and we could not find any in scientific papers too. Applications of the algorithm can be found in canal and highway design.

We did tests that tried to show the algorithm capabilities. Since no good data was available to generate realistic functions relating path construction or usage costs and slope, we used generic ones. The algorithm performed well, resulting in paths that were coherent with our assumptions. The iterative technique gives the algorithm the ability to calculate very complex paths, such as a spiral. The algorithm may obtain complete spirals if a turning cost is included in the cost function. The algorithm is also easily alterable to take into consideration other variables such as land use, geology and vegetation.

Acknowledgements

To Mr. David Douglas, of the University of Ottawa, to Mr. E. Stefanakis, of the University of Athens, Greece, and to CNPq, Brazilian research sponsoring agency.

References

Douglas, D. H. 1994 Least cost path in GIS using an accumulated cost surface and slope lines. Cartographica Vol. 31, No. 3; pp. 37-51. Eastman, J. R. 1995 Idrisi for Windows users guide. Clark University. Worcester. Jaga, R. M. N.; Sundaram, A.; Natarajan, T. 1993 Wasteland development using geographic information system techniques. International Journal of Remote Sensing, Vol. 14, No. 17, pp. 3249-3257. Jensen, S., Domingue, J. 1988 Extracting Topographic Structure from Digital Elevation Data for Geographic Information System Analysis. Photogrammetic Engineering. and Remote Sensing., v.54, n.11, p.1593-1600. Lee, J.; Stucky, D. 1998 On applying viewshed analysis for determining least-cost paths on Digital Elevation Models. International Journal of Geographical Information Science. Vol. 12, N. 8, 891-905.

Stefanakis, E.; Kavouras, M. 1995 On the determination of the optimum path in space. Proceedings of the European Conference on Spatial Information Theory, COSIT 95, Semmering, Austria. Springer-Verlag. Taha, H. A. 1996 Operations research: an introduction. Prentice Hall. 864p. Weber E.; Hasenack H. 1998 Anlise de alternativas de traado de um gasoduto utilizando rotinas de apoio deciso em SIG. GIS-Brasil 98. http://-

www.fatorgis.com.br/artigos/gis/gasoduto/gasoduto.htm. Xu, J.; Lathrop, R. G. 1995 Improving simulation acuracy of spread phenomena in a rasterbased Geographic Information System. International Journal of Geographical Information Systems, Vol. 9, No. 2, pp. 153-168.

S-ar putea să vă placă și