How to make a straight line square

Network Analysis in Raster GIS with time-dependent cost variables

Thesis for the MSc in GIS at University of Leicester 1999-2000

Author: Jan Husdal

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Abstract
Network analysis and least cost paths have long been the dominion of vector GIS. This research explores the topic of network analysis in raster GIS, using MFworks as example software. Current algorithms, procedures and network modelling techniques are investigated and common artefacts are explained. An extension of Tomlin's directional identifiers is proposed, allowing the modelling of non-planar features. Along with this, the integration of time- dependent travel cost variables is achieved through linking MFworks with an external Visual Basic application for updating the cost-ofpassage surface, demonstrating that such interaction extends the inherent capabilities of a GIS engine. Another conclusion to be drawn from this paper is that network analysis in raster GIS is a variant of surface analysis.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

2

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Table of contents
1 2 INTRODUCTION AND OUTLINE .......................................................................... 6 AIMS AND OBJECTIVES ......................................................................................... 7 2.1 2.2 2.3 3 VISION .................................................................................................................... 7 METHODOLOGY ...................................................................................................... 7 EXPECTED RESULTS ................................................................................................ 8

BACKGROUND RESEARCH AND LITERATURE REVIEW ............................ 9 3.1 GRAPH THEORY AND FASTEST PATHS ...................................................................... 9 3.2 FASTEST PATH ALGORITHMS ................................................................................. 10 3.2.1 Static fastest paths ....................................................................................... 10 3.2.2 Dynamic fastest paths .................................................................................. 11 3.3 FASTEST PATHS IN RASTER GIS ............................................................................ 12 3.3.1 Turning a surface into a network ................................................................. 12 3.3.2 Tomlin .......................................................................................................... 13 3.3.3 Eastman ....................................................................................................... 13 3.3.4 Douglas ........................................................................................................ 14 3.3.5 Xu and Lathrop ............................................................................................ 15 3.3.6 McIlhagga .................................................................................................... 16 3.3.7 Collischonn and Pilar .................................................................................. 18 3.3.8 Berry ............................................................................................................ 19 3.3.9 Network analysis or surface analysis ? ....................................................... 21

4

MFWORKS ................................................................................................................ 23 4.1 4.2 4.3 ABOUT MFWORKS ................................................................................................ 23 NETWORK ANALYSIS IN MFWORKS ...................................................................... 23 MFCOM ................................................................................................................ 25

5

APPLICATION DEVELOPMENT ......................................................................... 26 5.1 DATA ACQUISITION ............................................................................................... 26 5.2 NETWORK MODELLING ......................................................................................... 26 5.2.1 Incremental Linkage – inferring linear features.......................................... 27 5.2.2 Directional Identifier – constraining directions .......................................... 28 5.3 COST SURFACE MODELLING .................................................................................. 29 5.3.1 General considerations ................................................................................ 29 5.3.2 Determining travel cost and path length ..................................................... 30 5.4 IMPLEMENTING A DYNAMIC COST SURFACE .......................................................... 33 5.4.1 External application for updating cost surface ........................................... 33 5.4.2 Continuously updated cost surface .............................................................. 35 5.4.3 Time interval cost surface ............................................................................ 36 5.5 RECAPITULATING THE PROCESS ............................................................................ 38

6

DISCUSSION AND EVALUATION OF RESULTS ............................................. 39 6.1 6.2 6.3 6.4 6.5 CHOICE OF SOFTWARE .......................................................................................... 39 CHOICE OF DATA ................................................................................................... 40 GENERAL ACCURACY ............................................................................................ 40 SPREAD ARTEFACTS .............................................................................................. 40 CONTINUOUSLY UPDATED COST SURFACE............................................................. 43 3

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

6.6 6.7 6.8 7 7.1 7.2 8 9 10 11

TIME INTERVAL COST SURFACE(S) ........................................................................ 44 EXTERNAL VISUAL BASIC APPLICATION ............................................................... 44 MEETING THE OBJECTIVES .................................................................................... 44 MODELLING NON-PLANAR NETWORK FEATURES ................................................... 46 APPLICATION DEVELOPMENT ................................................................................ 48

FUTURE DEVELOPMENTS .................................................................................. 46

CONCLUDING REMARKS .................................................................................... 49 ACKNOWLEDGEMENTS ...................................................................................... 50 REFERENCES....................................................................................................... 51 APPENDICES ........................................................................................................ 54 APPENDIX A NETWORK ANALYSIS IN MFWORKS , STEP BY STEP ...................................... 55 APPENDIX B - NETWORK ANALYSIS IN MFWORKS, TRAVERSING TIME INTERVALS .......... 63 APPENDIX C - USING THE VISUAL BASIC APPLICATION .................................................... 69

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

4

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Table of figures
FIGURE 3-1: NETWORK REPRESENTATION IN GIS................................................................... 9 FIGURE 3-2: TRACING A PATH FROM CELL TO CELL IN RASTER GIS ..................................... 12 FIGURE 3-3: DOUGLAS' METHOD OF INTERPOLATING A LINEAR PATH .................................. 14 FIGURE 3-4: INFERRING LINEAR FEATURES IN RASTER CELLS, TOMLIN VERSUS DOUGLAS ... 14 FIGURE 3-5: SAMPLING METHODS FOR ACCURATELY SIMULATING SPREAD PHENOMENA ..... 15 FIGURE 3-6: MEASUREMENTS RELATED TO THE INCREMENTAL TIME OF THE LINK. .............. 16 FIGURE 3-7: EFFORT DISTANCE VERSUS FIXED COST DISTANCE. ........................................ 17 FIGURE 3-8: A PRACTICAL EXAMPLE OF EFFORT DISTANCE VERSUS FIXED COST DISTANCE . 17 FIGURE 3-9: LEAST COST PATH ALGORITHM. ....................................................................... 18 FIGURE 3-10: BEST ROUTE OF A ROAD UP A CONICAL MOUNTAIN. ....................................... 19 FIGURE 3-11: ADDING THE PROXIMITY SURFACES YIELDS THE OPTIMAL PATH. ................. 20 FIGURE 3-12: OPTIMAL PATH BETWEEN MULTIPLE DESTINATIONS ...................................... 21 FIGURE 4-1: FINDING THE OPTIMAL PATH USING MFWORKS ................................................ 25 FIGURE 5-1: DATA USED FOR EXPLORING NETWORK ANALYSIS IN RASTER GIS ................... 26 FIGURE 5-2: INCREMENTAL LINKAGE .................................................................................. 27 FIGURE 5-3: BUILDING A ROAD NETWORK FROM USING INCREMENTAL LINKAGE ............... 28 FIGURE 5-4: TOMLIN'S DIRECTIONAL IDENTIFIERS ............................................................... 28 FIGURE 5-5: INFERRING FLOW DIRECTIONS FROM INCREMENTAL LINKAGE VALUES ........... 29 FIGURE 5-6: TOMLIN'S INCREMENTAL LENGTH .................................................................... 30 FIGURE 5-7: ACTUAL PATH LENGTH AND INCREMENTAL LINKAGE PATH LENTGH ............... 31 FIGURE 5-8: SOUGHT PATH THROUGH A JUNCTION ............................................................... 31 FIGURE 5-9: INFERRED PATH THROUGH A JUNCTION ............................................................ 32 FIGURE 5-10: CORRECTLY MODELLED JUNCTION ................................................................. 32 FIGURE 5-11: EXAMPLE OF CORRECTLY MODELLED PATH THROUGH A JUNCTION ................ 33 FIGURE 5-12: TYPICAL USER INTERFACE FOR VISUAL BASIC APPLICATION ......................... 34 FIGURE 6-1 TYPICAL "MULTIPLE OPTIMAL PATH"-ARTEFACT .............................................. 41 FIGURE 6-2: SOLVING THE MULTIPLE PATH PROBLEM USING EUCLIDEAN DISTANCE ............ 41 FIGURE 6-3: SOLVING THE MULTIPLE PATH PROBLEM USING A COST SURFACE .................... 43 FIGURE 7-1: EXTENDING TOMLIN'S DIRECTIONAL IDENTIFIERS. ........................................... 47 FIGURE 7-2: MODELLING OVERPASSES AND CROSSING OF LANES......................................... 47

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

5

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

1 Introduction and outline
Imagine you are about to set out on a journey to where you’ve never been before. Of course, you take your road atlas and plan how to get there. You look for the fastest way. In doing so, you count miles, you choose major roads, look for short cuts, avoid urban areas, you may even think of what time you are going to travel at and how long it might take at that particular time. In practice, you are trying to find the fastest path through the road network. Computation of fastest paths is one of the most fundamental problems in route planning and has been subject to extensive research for many years. The majority of published research on fastest paths algorithms has dealt with static networks that have fixed topology and fixed costs for traversing the network, providing at best an averaged travel time. Contrary to that, this research will deal with dynamic networks, with time-dependent or randomly varying travel cost, as it de facto is in real-world networks. Furthermore, contrary to conventional standards, this research will be undertaken using raster GIS.

Raster-based GIS are not commonly known for network analysis capabilities. However, there is one existing software, MFworks, developed by Thinkspace, which has an extensive set of operators that enable network type analyses. The fact that MFworks is developed directly upon Tomlin’s map algebra operators (Tomlin, 1991) poses an interesting backdrop for this research.

The final inspiration for using raster GIS and MFworks in particular came through a review of rasterbased GIS and their capabilities in the June 2000 issue of GeoEurope (Limp, 2000), featuring MFworks as the only raster GIS capable of true network analysis. Triggered by this, the author decided to investigate the validity of this promotional claim.

Thus, the idea for this paper is to explore the topic of network analysis in raster GIS, using MFworks as example software, to discuss capabilities and limitations of raster GIS, to project possible improvements and to develop a concept for applying time-dependent travel cost in network analysis.

This research is undertaken in understanding with Thinkspace, and if successful, will provide a valuable extension to the functionality of MFworks.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

6

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

2 Aims and objectives
2.1 Vision
The overall vision for this research is the integration real-world events into route planning, ultimately allowing real-time traffic information to be used in calculating the optimal path through a continuously updated dynamic network.

The concrete aim of this research is to develop a method that allows a network analysis tool to find the fastest path through a dynamic network, simulating time dependent or randomly varying (“realtime) traffic.

From an academic viewpoint, a further aim of this research is to prove that network analysis is a function that is not restricted to vector GIS only, but is equally feasible in raster GIS, something the author has already pointed out in his previous research.

2.2 Methodology
Two approaches can be discerned:

A continuously updated network, where the latest available data at the starting time of travel is used, and where the cost of travel does not change during the duration of the estimated route.

A network with varying travel cost per pre-defined time interval, where the travel cost is dependent on the starting time of travel, and where the travel cost changes when the estimated route passes from one time interval to another.

In practice, the first approach involves building an application that passes on values to the cost surface used in a raster-based GIS for calculating the fastest path in a network. The second approach involves working with multiple cost surfaces for estimating the fastest path.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

7

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

2.3 Expected results
Both mentioned approaches are to be investigated and attempted implemented in MFWorks’ network analysis functions, as a paradigm for other raster GIS.

A proof that network analysis is feasible in raster GIS, based on Tomlin's map algebra operations.

A concept for calculating dynamic paths through a network.

A custom-built application for MFworks for calculating dynamic paths through a network.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

8

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

3 Background research and literature review
Euler’s famous “Königsberg bridge” question, dating back as far as 1736, is often seen as the starting point of modern path finding – was it possible to find a path through the city crossing each of its seven bridges once and only once and then returning to the origin? Euler's methods formed the basis of what is known as graph theory, and which in turn paved the way for path finding algorithms. Traditionally, network analysis, path finding and route planning have been the domain of graph theory and vector GIS, which is where most algorithms find their application. However, it is not difficult to adapt these algorithms to a raster environment, as will be highlighted in this chapter. Raster applications are more likely to be based on movement across a surface than movement along a network, since the general idea of finding the least cost path is linked to movement from cell to cell, and not along a finite line. Many researches have thus sought to improve the shortcomings of the raster approach and have developed various solutions and proposals. In order to appreciate their efforts, first, a synopsis of the conventions that encircle path-finding algorithms is necessary.

3.1 Graph theory and fastest paths
A network model can be defined as a line graph, which is composed of links representing linear channels of flow and nodes representing their connections (Lupien et al., 1987). In other words, a network takes the form of edges (or arcs) connecting pairs of nodes (or vertices). Nodes can be junctions and edges can be segments of a road or a pipeline. For a network to function as a realworld model, an edge will have to be associated with a direction and with a measure of impedance, determining the resistance or travel cost along the network, as shown in figure 3-1.

Figure 3-1: Network representation in GIS. From: Husdal (1999)
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

9

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Traditionally, a GIS represents the real world in either one of two spatial models, vector-based, i.e. points, lines and polygons, or raster-based, i.e. cells of a continuous grid surface. Since the modelling of network structures intuitively refers to lines and points, vector GIS has dominated the realm of network analysis. This research will show that network analysis is equally feasible in raster GIS.

3.2 Fastest path algorithms
Because path finding is applicable to many kinds of networks, such as roads, utilities, water, electricity, telecommunications and computer networks alike, the total number of algorithms that have been developed over the years is immense.

In 1979, Pang and Deo (1979) set up a nomenclature of shortest path algorithms, describing as many as 222 different algorithms, dating back as far as 1958. Their paper provides an excellent classification scheme, a brief description of each algorithm and highlighted comparisons of particular algorithms.

Semantically one can distinguish between path finding in a fixed static network, with set costs for traversing the network, and path finding in a dynamic network, where the cost of traversing the network varies over the time of traversing.

One way of dealing with dynamic networks is splitting continuous time into discrete time intervals with fixed travel costs, as noted by Chabini (1997). Thus, understanding shortest path algorithms in static networks becomes fundamental to working with dynamic networks.

3.2.1 Static fastest paths The majority of published research on shortest paths algorithms has dealt with static networks that have fixed topology and fixed costs. Given the computational restraints in the capacity of past computer systems this is not surprising. Not more than a decade ago, Van Eck (1990) reports several hours as an average time for a computer to churn through an all-to-all calculation on a 250nodes small-scale static network, and several days on a 16.000-nodes large-scale network.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

10

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Several algorithms and data structures for algorithms have been put forward since the classic shortest path algorithm by Dijkstra (1959). This algorithm computes a path in all directions from the origin node and terminates when the destination has been reached.

The original Dijkstra algorithm explores all directions from the starting node, thereby searching an unnecessary large search area. This led to the development of heuristic searches, among them the A*algorithm, introduced by Mitchell and Kiersey (1984), that searches in the direction of the destination node. This avoids considering directions with non- favourable results and reduces computation time.

Another improvement is seen in the bi-directional search, computing a path from both origin and destination, and ideally meeting at the middle, which then terminates the search. However, as Dreyfus (1969) notes, in certain cases, the number of iterations required may actually exceed the Dijkstra algorithm, or even produce a false result.

The A* algorithm, along with Dijkstra-based algorithms, seems to be preferred in most of the literature researched by the author. It is in fact noteworthy that the Dijkstra algorithm has prevailed to the present date, proving its universal validity.

3.2.2 Dynamic fastest paths A few early attempts on dynamic approaches, referenced by Chabini (1997), are Cooke and Halsey (1966) and Dreyfus (1969). Current literature suggests that dynamic network fastest path problems can be reduced to static fastest path problems if continuously varying link travel times are expanded for a time interval or given an estimated value. This makes the A* and Dijkstra algorithms applicable in both static and dynamic networks. Adaptations of Dijkstra's algorithm are frequently found in raster GIS application, thus it seems natural not to delve more deeply into various dynamic path algorithms, as these are in most cases applied in graph theory, and not related to the research undertaken here.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

11

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

3.3 Fastest paths in raster GIS
Even though vector GIS has dominated the network analysis scene, this does not mean that finding the shortest path is not viable in a raster environment. However, in order to understand network analysis in raster GIS, the particular properties of raster GIS must be understood first.

3.3.1 Turning a surface into a network In a raster GIS cartographic space is defined as a surface, where the value of a particular property varies over this surface. In order to adapt a network structure, each cell may be seen as a node linked to its eight neighbouring cells. The cell value of each node then can represent the cost of traversing this particular cell. This cost-of-passage surface is a grid where the values associated with the cells are used as weights to calculate least cost paths. These weights may represent the resistance, friction or difficulty in crossing the cell and may be expressed in terms of cost, time distance or risk (Collischon and Pilar, 1999). Starting from a given destination cell, it is then possible to spread outward and calculate for each surrounding cell, the accumulated cost of travelling from any surrounding cell to the destination cell. From this accumulated surface it is then possible to delineate the shortest or least-cost path to the destination cell from any surrounding cell (Douglas, 1994), simply by following the path with the least accumulating friction.

This network adaptation from a surface has its shortcomings. A straight line indicating the shortest or least-cost distance from a starting node to a destination node must follow a zigzag line directed by the grid resolution, and thus only can approximate the correct distance (Fig 3-2).

Figure 3-2: Tracing a path from cell to cell in raster GIS generates a zigzag path instead of a straight line.

There are three main network problem types, related to the ways that weights or resistances are assigned to each of the network links: isotropic, partially anisotropic, and fully anisotropic. In an isotropic network, the cost-of-passage is dependent on location only, and the surface consists on one or multiple homogenous and coherent patches. Resistance is independent of direction, i.e.
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

12

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

equal in all directions. The second type has direction-dependent cost, but with one prevailing direction over the whole surface, as is the case in the fire spreading study in Xu and Lathrop (1995). In a true anisotropic network the cost of passage is direction-independent and varying over the whole surface, as is the case in most road networks (Collischonn and Pilar, 1999).

3.3.2 Tomlin The concepts surrounding surface analysis for optimal paths date back to late 1970s (Berry, 2000; personal communication), and were later championed by Dana Tomlin with his dissertation (Tomlin, 1983), which was later published as a book. Here, Tomlin (1991) classifies his map algebra operators based on how the computer algorithm obtains data values for processing and identifies three fundamental classes: local, focal and zonal functions. He introduces a spread algorithm (focal function) for calculating proximity surfaces, delineating the shortest possible distance from any location to a destination point. In this method, all cells are initialised to no value. Passes are then made through the image with each cell checking the cost of travel from each of its adjacent cells that contain a value. If the incremental effort distance is less than the difference in cumulative cost or the cell contains no value then the cell requires updating to a new value. Once a pass is completed without any changes, the cost surface has been generated (Tomlin, 1986; McIlhagga, 1997).

3.3.3 Eastman McIlhagga (1997, see below) notes that Tomlin’s method is efficient for small areas or narrow passages such as a road network; however it becomes very inefficient when large images are processed. Ronald Eastman remarks that “a 512 by 512 grid could require 700 passes” to produce a cost surface (Eastman, 1987). As part of the IDRISI GIS system, Eastman implemented a second algorithm to generate cost surfaces called the pushbroom procedure. “...the [procedure operates] by pushing effects through the image, much like a pushbroom would be used to systematically clean a room. Effects then ripple through the image, much like water being pushed over a wet floor.” (Eastman, 1987). The cost surface image is initialised with no values except the target cell and a pass through the image is made from upper right to lower left with each cell updating the cell to the right and each cell below. In this manner all following cells are updated so that the most recent change is pushed forward with each successive update. Generally, three passes has been found to be enough to generate a cost surface (McIlhagga, 1997).
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

13

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

3.3.4 Douglas Douglas (1994 and 1999) attempts to overcome the limitations of a zigzagging least-cost path by interpolating the line of the path over the cell. The path does not follow a straight line from centre to centre, but is determined by first dividing each cell into four triangular facets and then tracing the path through the four facets (Fig 3-4).

Figure 3-3: Douglas' method of interpolating a linear path across a raster cell. From: Douglas (1999)

Douglas' procedure is an improvement, as the optimal path is more clearly and accurately delineated than in a fixed grid with only 8 directions as used by Tomlin. Figure 3-4 shows one possible comparison between Tomlin's and Douglas' concepts.

Figure 3-4: Inferring linear features from raster cells, (left) neighbouring cells, (middle) Tomlin's Incremental Linkage, (right) Douglas' interpolation, showing one possible solution

Douglas' method of tracing the least-cost path demands a partially anisotropic surface, and assumes that any least cost-of-passage is prevailing in the direction of the steepest slope. In a road network this is most often, or maybe always, not the case, as shown by Collischonn and Pilar (2000).

In personal communication, Douglas remarks that the reason for this is his view of cell values as samples of a location surface. Thus, any link between cells will not necessarily be a straight line between cell centres, but must be found by interpolation, since the cell centre itself is a sample value.
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

14

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

3.3.5 Xu and Lathrop An attempt to overcome zigzagging outlines of spread zones was undertaken by Xu and Lathrop (1995). Using the 8 adjacent cells as directions for outward spread leads to an overestimation of travel time and an underestimation of outward spread distance, because the conventional 8-cell link approach inadequately simulates a spread shape, since too few links out of all possible links are evaluated for connecting properties. Thus, their algorithm investigates the efficacy of adding additional cells beyond the conventional 8 neighbouring cells as links in the algorithm. These cells are not adjacent to the spread cell, but can be regarded as connected to it through the cells that are in-between. Figure 3-5 displays some possible sampling methods.

Figure 3-5: Sampling methods for accurately simulating spread phenomena. From: Xu and Lathrop (1995)

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

15

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-6: Measurements related to the incremental time of the link. From: Xu and Lathrop (1995)

Figure 3-6 illustrates how Xu and Lathrop calculate the path from the spread cell to any given link cell. The accumulated cost-of-passage then from cell X to a non-adjacent cell Y is equal to the sum of the incremental costs for each leg X i to Y Euclidean distance from X to Y, see fig 3-6.
i

along the link from X to Y, calculated in direct

3.3.6 McIlhagga McIlhagga (1997) introduces a new term: fixed-cost distance, as opposed to the usually applied effort-distance; costs associated with effort distance are incurred every time a movement over a path occurs or more generally, movement between cells. Fixed cost distance is the cost associated with creating a path for linking multiple cells to a destination, and is incurred only once, when the path is created. Thus, minimising effort distance involves minimising the cost from a given point to any target (the accumulated cost surface for this given point); minimising fixed cost distance requires finding the optimal path that connects a point to all targets regardless of minimising the path to any of these targets in isolation (McIlhagga, 1997). Figure 3-7 gives a simple illustration McIlhagga's fixed cost distance.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

16

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-7: Effort Distance versus Fixed Cost Distance. From: McIlhagga (1997)

Later developed into software called "Pathways", the core algorithm in McIlhagga's research is an extension of Ron Eastman's Push Algorithm applied for multiple targets. In general, the algorithm "builds" optimal cost surfaces for combinations of targets until all targets have been included. The key issue for the "Pathways" algorithm is to optimise and predict which combinations will provide the greatest contributions to a final solution. So for instance, if it is possible to predict that the combination of target X and target Y with target A & target B provides very useful values this can mean that all the other sub-combinations to get to this point do not need to be calculated and can be discarded. A finely tuned prediction engine can result in huge optimisations (McIlhagga, 2000; personal communication). Figure 3-8 shows a practical example of finding the optimal path from a forest road to logging sites.

Figure 3-8: Effort distance finds the shortest paths from target to nearest road (left), while fixed cost distance finds the optimal path linking all targets, if possible, to one path (right). From: McIlhagga (2000).

McIlhagga disagrees with Tomlin and Berry on their method of tracing the optimal path where the least accumulated friction is, or as Douglas put it, the steepest downhill slope. McIlhagga claims that the most optimal path algorithm is to select he adjacent cell from a start point where the incremental cost between them is equal to the difference in cumulative cost to the target delineates an optimal path (McIlhagga, 1997), as shown in the following example:

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

17

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-9: Least cost path algorithm. Target is cell at row/column 2/2. Left: cost surface, middle and right: accumulated cost surface from target cell. Middle: Incorrect path following largest descent from cell at 3/5. Right: Correct path following accumulated cost. Adapted from McIlhagga (1997)

Given the cell in row/column 2/2 as target, if Following Tomlin, the shortest path from the cell at row/column 3/5 to the target will first go to the cell at 2/4, since this path has the steepest fall in accumulated cost. The correct path is via the cell at 3/4. The reason is clear: The shown value for the difference in accumulated cost from cell 3/5 to cell 2/4, without considering how the values were inferred, is equal to 2.6 for the incorrect path. However, the calculated value from cell 3/5 to cell 2/4 is (0.7x2 + 0.7x2) equal to 2.8, indicating a discrepancy. For the correct path, the values are 2.0 and 2.0 for the shown and calculated values respectively, thus making the right path in Figure 3-9 the correct delineation of the least cost path.

3.3.7 Collischonn and Pilar Collischonn's and Pilar’s concept of least-cost-paths is particularly worth mentioning, because it not merely traces a path down a cost surface like so many others, and presents the path following the least friction as the least cost path, but it links the cost of traversing the slope to the degree and direction of the slope itself. Thus, forcing a path down a steep slope may in fact be more costly than a descent that circumvents the steepest directions. This view coincides with conventional planning procedures for roads and canals, where the topography adjacent to the path plays a major role in determining the most viable route for the least cost path. Their algorithm uses a cost-slope function to assign accumulated cost to cells in 3X3 window around a centre cell. The steeper the slope is, either uphill or downhill, the higher the cost will be, thus favouring directions with no or little difference in slope. As a result of this procedure, the least-cost path up or down a hill is not the straight line following the steepest path, but a path that winds or climbs the hill sideways (Fig 3-10).

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

18

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-10: Best route of a road up a conical mountain. From: Collischonn and Pilar (2000)

It may look like an artefact inherent in the algorithm, but nevertheless, their procedure produces hairpin-like bends in the path, much in the same manner that an ordinary road on a hillside might have.

3.3.8 Berry Berry (2000a) uses a concept similar to Tomlin; he calls his algorithm "Splash" rather than "Spread". Berry's map operators differ from Tomlin, although they are used for the same purposes. Berry's classification scheme is based on the user's perspective of map input and output contents; what the map(s) look like going in and coming out: reclassify, overlay, distance and neighbourhood. The Splash algorithm belongs to the distance division.

According to Berry, each grid space on a friction map or cost-of-passage map is coded with the “relative cost” of traversing that location. Increased impedance is translated into the steeper slopes, so that a slope map of an accumulation surface unmasks the relative ease of optimal travel through each grid space. The notion of “optimal movement” embedded in an accumulation surface is important to understand the algorithm. The “splash” algorithm used to build the surface considers movement from the eight surrounding cells to each location. The accumulated distance and the relative impedance for each of the eight potential “steps” is evaluated. The least costly step, in terms of total movement, is assigned. Therefore an aspect map of an accumulation surface unmasks the direction of optimal movement through each grid space. Thus, the optimal path from any location to the origin is identified as the steepest down hill route over the surface. To find the optimal path between two points, Berry suggests the creation of an accumulation surface for both points, and adding them together, see figure 3-11.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

19

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-11: Adding the proximity surfaces generated by spreading from 2 points yields the optimal path. From: Berry (2000a),

The optimal path between the two locations (identified by the line in both the 2-D and 3-D views in figure 3-11) contains the set of locations having the lowest values (a valley connecting the origins). The saw-toothed appearance of the optimal path is an artefact of arithmetic rounding, the nature of the splash algorithm and minimal friction outside the barrier in the centre. Values above the valley floor indicate the length of the best, but sub-optimal paths forced through any location. In addition to finding the optimal path, the values on the summation surface identify the length of the “best” path, where the term length indicates whatever is used as measure for the cost-of-passage, be it distance, time, fuel consumption or other units of measure. As an interesting side note, the difference between the lowest value on the summation surface and the value at any other location identifies the “opportunity cost” of forcing a route through that location (Berry, 2000a). Berry also develops a concept for finding the path between multiple targets, using what he calls a stepped accumulation surface. First the optimal path is calculated from point one to point two, then from point two to point three, and further repeating the procedure for any number of points along the route (Figure 3-12). However, this procedure does not calculate the best order of points along the route; points are visited in the order they appear.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

20

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 3-12: Optimal path between multiple destinations using a stepped surface. From: Berry (2000a)

According to Berry (2000a) the stepped accumulation surface can be used as a directed surface, calculating the optimal path with the points in the given (directed) order or as an undirected surface, with the points in the best (undirected) order. In practice, this involves calculating all possible combinations of the stepped surface and evaluating the best combination of these. For the research presented in this paper, this concept can be applied in calculating the optimal path through successive time intervals, since it is the best-order combination of the various paths through the time intervals that will determine the least-cost path. An interesting application of the stepped accumulation surface is found in Berry (2000b), where instore shopping patterns were analysed, proving that spatial analysis is not necessarily restricted to outdoor phenomena.

3.3.9 Network analysis or surface analysis ? To sum up, much of the literature on fastest or least cost paths in raster GIS described above have focused on surfaces rather than networks, and have extensively linked slope and aspect to the propagation of the path. Consequently, the algorithms and findings presented may seem inapplicable to road networks, as demonstrated by Collischonn and Pilar (2000).

There are also variations in approaches and methodology. Xu and Lathrop attempt to smoothen Tomlin's octagonal isolines around a spread centre, Douglas is concerned with making the path follow an interpolated line rather than a zigzag path directed by the grid structure. McIlhagga focuses on multiple targets and the connecting path between them. Collishonn and Pilar seek to detach the least-cost path from the traditional path-following-steepest-slope concept and Berry maintains his view of surfaces as continuous space.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

21

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

The transition from surface to network is however not difficult to follow: The difference between a surface and a network is that in a network, non-linked or non-networked cells constitute a surface with an infinitely large friction or cost-of-passage, posing an impermeable barrier. Spreading can only take place along the defined network. The procedures and algorithms used in networks are basically the same as one would use on continuous surfaces: Finding the optimal path between 2 points is done is done by adding the proximity surfaces for these 2 points. For multiple points the calculation becomes more complex, but follows the same principles.

The generic structure of raster GIS facilitates an approximation and distortion of smoothly curved real-world network features. Nevertheless, the same structure also visualises and draws attention to the spatial context that the least-cost path is set in.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

22

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

4

MFworks

Even though this research was undertaken using a particular software, namely MFworks, the process of network analysis would be similar in any software that implements Tomlin's networkrelated map algebra operators. The following is meant to give a brief description of the software used and the process involved, in order to familiarise the reader with the terms and figures that appear in later chapters.

4.1 About MFworks
MFworks is a pixel-based GIS, developed by Thinkspace Inc., which can process images and maps both visually and quantitatively. C. Dana Tomlin developed the precursor to MFworks, the Map Analysis Package, and MFworks makes extensive use of the map algebra developed by Tomlin, something that is unmistakably recognisable in the menu and scripting commands. Interestingly enough, a major North American power utility, Hydro Quebec, uses MFworks exclusively for their least cost/shortest distance analysis, thus proving it's feasibility (Thinkspace, 2000; personal communication).

4.2 Network Analysis in MFworks
Network analysis in MFworks follows the pattern outlined in the previous chapter; see Tomlin (3.3.2) and Berry (3.3.8). Spreading through a cost-of-passage surface from a given point creates an accumulated-cost-of-passage surface. Two surfaces are created, one for spreading from departure and arrival point respectively, taking into consideration any directional constraints imposed by the network (see 5.2); these surfaces are then added to each other, resulting in a accumulated cost surface, where the location of the cells with lowest values indicate the demarcation of the least-cost path and the cell values state the path's effective cost, as described by Berry (2000a).

In the following the MFworks internal language term "map layer" will be used interchangeably along with "surface", where map layer relates to a specific object created in and used by MFworks, and surface relates to the generic objects described in the previous chapter.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

23

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

The procedure of finding the least-cost path can be divided into two parts. The first step is the creation of the necessary map layers:

Create Cost Layer Cost Create Directional Constraint Layer Directions Create Departure Layer Start Create Arrival Layer End

The second part is the process of path finding, here described in terms of the MFworks scripting language, to illustrate the close resemblance to the terms used in GIS and Cartographic Modelling by Tomlin (1991).

SpreadFromStart = Spread Start In Cost Outof Directions

SpreadFromEnd = Spread End In Cost Outof Directions

ShortestPath = SpreadFromStart + SpreadFromEnd, Isolate lowest values Graphically, this will result in the following screen images, if using a fictitious inner city road network as an example (Figure 4-1):

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

24

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 4-1: Finding the optimal path using MFworks, from top left to bottom right: cost surface, starting point, ending point, directional constraints, resulting path after adding proximity surfaces and isolating lowest values

Even though this seems simple and straightforward, caution must be used, as improper or oversimplified modelling of the cost factors leads to multiple shortest paths, as discussed in 6.3. Another reason for applying meticulous care in modelling is that networks in raster GIS are a mere approximation of real world networks, thus being predominantly prone to modelling artefacts. A description of and solution to some particular problems will be given in the following chapters.

A detailed step-by-step description of performing the path-finding process described in this paper is given in appendix A and B.

4.3 MFcom
A noteworthy extension to MFworks is MFcom. Using an object-oriented approach, the components of MFworks have been translated into MFcom modules that can be put together into task-specific applications and tailored-user interfaces using Visual Basic or C++ programming language. The reason for mentioning this is because this research was initially aimed at designing an MFcom network analysis application.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

25

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

5 Application Development
The development of a raster GIS application for network analysis comprises iterative steps that lead to a functioning network. Particular care must be shown in modelling the network structure to comply with the network-related features of Tomlin's (1991) map algebra operations. This will convert map layers with square cells into linear elements that are linked together as lines with directional flows assigned to each cell, and map layers containing cost variables. Applying time-dependent cost of travel involves building an external Visual Basic application that will interact with the map layer containing the travel cost data, for updating the values used in the least-cost path calculation.

5.1 Data acquisition
The data for this research was acquired from two sources: By recreating the Brown's Pond Study Area from Geographic Information Systems and Cartographic Modelling by Tomlin (1991) and by using simulated data to demonstrate and evaluate the concepts presented in this paper. The first was chosen for the reason of familiarity, since MFworks is based on Tomlin's map algebra, and thus the author felt obliged to use the same study area in the exploration of this paper's topic as was used by Tomlin in his original study. The latter is a simple lattice, where it is easy to apply various settings as to direction and travel costs, and to compare the results.

Figure 5-1: Data used for exploring network analysis in raster GIS: (left) a recreation from Tomlin's GIS and Cartographic Modelling, (middle) roads layer isolated from left layer, (right) fictitious street network

5.2 Network modelling
The key to producing a successful network model is in understanding the relationship between the characteristics of physical network systems and the representation of those characteristics by the
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

26

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

elements of the network model. The efficacy and validity of the network depends on how precisely the network can be modelled to match the real world network it represents (Husdal, 1999)

As mentioned earlier, the graph network, which can be explicitly modelled in vector GIS, can only be approximated by the raster GIS cell structure. Using Tomlin's Incremental Length, Incremental Linkage, and Directional Identifiers, which identify underlying linear features, it is possible to model a road network in raster GIS in much the same manner as in vector GIS. The first step is to extract linear features from neighbouring raster cells; the second step is to assign directions.

5.2.1 Incremental Linkage – inferring linear features This operation, as described by Tomlin (1991), infers the lineal characteristic of raster cells, by equating consecutive locations with a set of straight lines between them (Figure 5-2). Based on its relations with neighbouring cells that have the same attribute value, each cell is given a linkage value indicating how it is linked to other cells.

Figure 5-2: Incremental Linkage, cell value infers the linear structure it represents. From: Thinkspace (2000)

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

27

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

By assigning a value to each cell equivalent to the linear feature it represents it is possible to create a network similar to a road network (Figure 3-5). The smaller the cell resolution, the better the realworld road network will be approximated by this procedure.

Figure 5-3: Building a road network from figure 5-2 using Incremental Linkage with cell values representing linear features

5.2.2 Directional Identifier – constraining directions The second step to creating a road network in raster GIS is to impose constraints on the flow that can take place from cell to cell. Tomlin was among the first to introduce the idea of inferring the flow to or from a cell and its eight neighbours. The value assigned to the centre cell in a 3x3 window would then indicate the directions the flow can take in and or out of this cell. Initially used in conjunction with inferring the direction of steepest slope over a surface, and thus drainage, in networks it can be utilised for explicitly allowing or prohibiting flow in certain directions. Figure 5-4 shows how a cell value of 10 is inferred from flow in direction 8 and 2.

Figure 5-4: Tomlin's directional identifiers, cell values indicate possible flow direction in or out of cell

The directional identifiers that are to be assigned to any given cell in a road network can be directly inferred from the Incremental Linkage values, i.e. Incremental Linkage value 28 yields directional constraints value 10, and so on. The transition from Incremental Linkage to Directions is done through a straightforward reassigning of the cell values in the Incremental Linkage map layer to corresponding values in the Directions map layer. More specific constraints, like one-way directions

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

28

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

or dead-end roads, which are not directly inferable from the mentioned linkage values, will have to be assigned manually.

Figure 5-5: Inferring flow directions from Incremental Linkage values in figure 5-3

Although this procedure has now created a fully functional network, one of the limitations of network modelling in raster GIS comes, literally speaking, to the surface. A raster can only represent a surface, whereas a road network only in very few cases can be viewed as a planar surface.

5.3 Cost surface modelling
5.3.1 General considerations Usually, to generate a cost-of passage surface, several variables will to be collapsed into one layer. These variables might be road class, average speed, traffic density, and congestion during specific time of day or other factors that contribute to the overall cost variable. The cost-of-passage surface can be defined by a variety of measurement units: time, fuel consumption, money or other possible cost units, for which the least cost passage is to be determined.

In a study in Portugal to estimate tourism potential for a certain area, da Costa (1996) used a 100m grid size, where the cost-of-passage was inferred by deriving the time for traversing each cell from the average speed at that particular location. Using average speed and time as a means of inferring cost-of-passage is among the most common approach in network analysis, since it is easy to use and calculate. However, as pointed out earlier, "least cost" does not always need to be "least time"; it may just as well be least fuel, least length, or any least cost variable that can be implemented in a cost-of-passage surface.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

29

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

5.3.2 Determining travel cost and path length To determine the actual length of a path through a number of cells the Incremental Length operation is used. Incremental Length works similar to Incremental Linkage to the extent that Incremental Linkage is used implicitly to determine the linkage, from which the length is inferred. Incremental Length then applies the factor by which the cell resolution has to be multiplied to yield the length of the linear features in any cell.

Figure 5-6: Tomlin's Incremental Length, cell values indicate factor for calculating length of linear features. From Thinkspace (2000)

It should be noted that Incremental Length calculates the factor for inferring the total length of all linear features in any cell. When uncritically applied to deriving the time of traversing a cell, this function may not yield exact results, since the time of passing straight through a cell may differ from the calculated value, which takes into account all linear features in that cell, even those that are not traversed. The smaller the cell resolution and the higher the average speed, the more negligible this error becomes.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

30

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Grid (m) 10 20 50 100

size

Incremental Length (m) 126 252 630 1260

Path Length (m)

Difference

at

Difference

at

60 km/h (secs) 94 188 470 940 0.64 1.28 3.2 6.4

30 km/h (secs) 1.28 2.56 6.4 12.8

Figure 5-7: Assessing discrepancy between actual path length and length inferred from Incremental Linkage

Figure 5-7 demonstrates an example of this "error". The bold line is the path sought; the shaded cells indicate where the Incremental Length factor deviates from the actual length. The table shows how cell resolution and average speed influence the magnitude of the error.

To determine the length of a particular road stretch, this stretch first has to be separated, then made subject to the Incremental Length operator to find the correct length. Whether this last procedure is absolutely necessary will depend on the cell resolution and whether deriving the actual path length is strictly required as a result of the task in question.

A special case, illustrating the discrepancy between inferred and actual path length, as described previously, appears at crossroads and junctions and deserves particular attention, especially at non90-degrees junctions, as shown in the following example:

Figure 5-8: Sought path through a junction

The actual path sought is a straight line through the junction, indicated by the shaded cells. The bold lines indicate the actual linear features. The actual path length is cell resolution x 5.6 (1.4 x 4).

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

31

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 5-9: Inferred path, as result of Incremental Length/ Incremental Linkage

In order to justify the inferable directions, the Incremental Length operator will link to many cells together, as shown by the shaded cells and bold line. The inferred path is equal to cell resolution x 8.2 (1.7 x 2 + 1.4 x 2 + 1 x 2), thus overestimating the actual path over this section by 2.6 x cell resolution. Unless there is substantial difference in cost-of-passage between the two roads that cross each other, which then prohibits the off-path cells from being included in the added proximity surfaces, this error will occur in most cases with such junctions.

Figure 5-10: Correctly modelled junction, linkage indicated by bold lines, direction indicated by arrows

A solution to avoid this from the beginning, before finding the least-cost path, would be to model the linkage correctly, and allow the direction to flow differently. The fact that it is possible to completely detach the direction of the flow in a network from the underlying linear feature is indeed an interesting observation concerning the modelling of networks in raster GIS.

The above can also be demonstrated by an example from the study area. Note the linked square in the left image, as opposed to the straight line in the right image:

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

32

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 5-11: (a) Least-cost path using generically inferred directions, (b) Location of a and c in study area, (c) Least-cost path using manually inferred directions

A detailed step-by-step example of finding the least-cost path using MFworks is given in appendix A.

5.4 Implementing a dynamic cost surface
For implementing an dynamic cost surface, these two approaches can be identified: One option is to use a continuously updated network, where the latest available data at the starting time of travel is used, and where the cost of travel does not change during the duration of the estimated route. Another option is to establish a network with varying travel cost per pre-defined time interval. In this case the travel cost is dependent on the starting time of travel, and the travel cost changes when the estimated route passes from one time interval to another.

In practice, the first approach involves building an application that passes on values to the cost surface used in a raster-based GIS for calculating the fastest path in a network. The second approach involves working with multiple cost surfaces for estimating the fastest path. Both methods will be considered in the course of this research.

5.4.1 External application for updating cost surface MFworks offers the possibility to export map layers as a text file in tab-delimited format. Thus, it is possible to export the cost surface from MFworks as a tab-delimited text file, which is then edited in Visual Basic or other programming languages, such as Java, and then re-imported into MFworks, for use in calculating the least-cost path.

The tab-delimited format was chosen, since it is a common format, particularly for exchanging data to and from databases, where the key issue is to be independent of any proprietary data format inherent in the database used (i.e. MS Access, Oracle or FoxPro). Manipulating tab-delimited files in Visual Basic then is a rather trivial task. A further reason for choosing Visual Basic was with the
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

33

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

intent to integrate this application into an MFcom environment. Finally, and most importantly, Visual Basic allows for rapid application development, minimising the time necessary to create external applications for interacting with other applications, particularly database applications.

The Visual Basic application is a standalone application that can run independently of MFworks. The application interface offers manual updates or continuous updates, where the user selects the time interval between updates. In calculating the accumulated cost of passage, MFworks will then automatically use the latest updated cost surface. To simulate real-time information the cost surface is updated with random values.

Figure 5-12: Typical user interface for Visual Basic application for external updating of cost surface

In practical terms, the application reads the tab-delimited xyz-file (with a columns for x-coordinate, ycoordinate and z- (attribute)-value respectively), and exchanges the value in the third column (zvalue) for a random value.

A detailed explanation of how to use the Visual Basic application is given in appendix C.

As a digression, it is worth mentioning that in the process of building this application, minor problems in the import function of MFworks were discovered, errors that did not flaw the results, but caused some annoyance and required additional user-interaction that could have been saved. The errors were duly reported to and acknowledged by Thinkspace's technical support.
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

34

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

5.4.2 Continuously updated cost surface To simulate real-time information the cost surface is updated with random values via a standalone Visual Basic application. The cost surface is first exported from MFworks as a tab-delimited text file, which is then edited in Visual Basic, and re-imported into MFworks.

There are 2 possible approaches to implementing time-dependent travel: In the conventional and typical raster oriented approach, each variable that contributes to the cost surface is contained in a separate layer, where the final cost-of-passage variable for each location is calculated as a result of algebraic operations on the various layers at each location. In a different approach, a layer is constructed, where each cell is given a unique identifier, this identifier is used as key to a database that holds the final cost-of-passage variable for each location. In this case the calculation of the final variable takes place within the database.

Whenever the least-cost path is calculated in MFworks, the latest updated cost values are used, whether they are derived from multiple layers or a database. It should be noted that this calculates the least cost path as it can be discerned for the time of starting the travel. In both of the approaches cited it is assumed that the cost-of-passage for each cell remains unaltered during the entire passage, regardless of the time it takes to traverse the path.

Using multiple cost variables, the surfaces for each variable can be updated independently of each other, before they are collapsed into one value by map algebra operations. This method would imply external, not necessarily Visual Basic, applications for each of those variables, and separate computation procedures.

Another option is to assemble an external database, which holds all variables, and then transfers one calculated value only to a collapsed cost-of-passage surface. Given the inherent database connectivity possibilities in Visual Basic, this option is preferable to multiple cost surfaces, albeit this ultimately is dependent on end-user preferences.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

35

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

5.4.3 Time interval cost surface This approach uses an average cost-of-passage surface for each time interval. If one-hour time intervals were used, one would need 24 cost surfaces to cover a 24-hour period. Using multiple cost surfaces for traversing multiple time intervals is analogous to the stepped cost surface described by Berry (2000a). Applied within the context of time intervals, the first proximity surface is cut off when the time interval border is traversed. Then, from all endpoints, new proximity surfaces and shortest paths are calculated, until the destination is reached. Computationally this can turn into a considerable task, depending on the number of time intervals traversed and the number of paths generated in each time interval: If time interval A yields 4 possible paths from a starting point, then for time interval B, the four paths must be continued until the destination or a new time interval is reached. When the destination has been reached the values of all paths must be added and compared. In practice, one must calculate proximity surfaces from a starting point to cut-off points where a new time interval begins, and from cut-off points to starting point, adding the surfaces yields the accumulated cost-of-passage (time) value for each path. Then, from each cut-off point the procedure has to be repeated until destination or a new time interval is reached. Finally the accumulated cost-of-passage value for each successively linked path must be calculated and compared to find the path with the lowest accumulated value.

In detail, the steps would be as follows: 1. Input Network, with 3 possible ways from starting point to destination point.

Step 1 Spread from starting point, cut-off when accumulated cell values indicate that a time interval borderline is being passed. Then, spread backwards from the cut-off points to starting point. Adding the proximity surfaces yields the cost-of-passage for this time interval for the various paths.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

36

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Step 2 For all cut-off points, spread until next time interval or (in this case) until the destination has been reached. Spread backwards from destination and add proximity surfaces to yield the cost-of-passage values for all possible paths. Retain the paths from the cut-off points to destination that have the lowest cost-of-passage.

Discard other paths

Step 4 Add the cost-of passage for the partial paths to yield the final cost-of-passage value for the remaining paths. Retain the path with the lowest value.

A detailed case study of this approach is given in appendix B.
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

37

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

5.5 Recapitulating the process
Enabling network analysis in raster GIS means a) employing Tomlin's Incremental Linkage to infer linear features, and b) using directional constraints to explicitly divert the flow in the network. Directions do not need to follow the underlying linear features. Directions are needed to delineate the course of the path(s); linear features are needed to calculate the path length, using Tomlin's Incremental Length.

Implementing dynamic cost variables can be done by a) updating either one cost surface or multiple surfaces representing various factors that contribute to the cost-of passage, or b) by using timedependent cost surfaces, depending on the time interval the travel takes place in. Time intervals and paths through these can be calculated consecutively. The more time intervals to be traversed, the more calculations are to be processed.

Updating dynamic cost surfaces is done via an external application, in this case using Visual Basic, and demands that the GIS software used can interact with external applications by exporting the cost surface to the application in a format that the application can process.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

38

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

6 Discussion and evaluation of results
Even when meticulous care has been taken in modelling the network to match the concepts described previously, it may still not produce the desired results when tested thoroughly. There may be many reasons for this. Firstly, it may be associated with the software and data involved, it may also be a result of the inevitable approximation when a finite network is to be modelled in a surfacefavouring environment. One particular problem is the so-called multiple-path-problem, to which a solution is given below. Finally, it is also time to reflect upon the objectives and whether they were achieved as set out or not.

6.1 Choice of software
The most striking reason for choosing MFworks was the fact that MFworks is the only software implementing Tomlin's Incremental Linkage and Directional constraints, which are a precondition to conducting network analysis. Taking into account the underlying modelling assumptions, MFworks lived up to the expectations the author had prior to his research.

It deserves mentioning that similar grid-based analysis operations to the operations in MFworks, apart from Incremental Linkage and Directional constraints, exist in Idrisi, ARC/INFO GRID, ILWIS, the various MAP (Map Analysis Package) editions (MAP, aMAP, pMAP) and in MapCalc, to name the probably most renowned competing software packages. However, there are significant programming structure and command syntax differences. Some use a "natural language" command language of simple phrases forming fully structured, short sentences. Others use a computer programming structure, similar to C++, where each command is written as an "assignment-operator" equation with the command and processing specifications forming an order dependent, alphanumeric string.

Since MFworks was uses an easy to understand natural language, close to Tomlin's map algebra operators, this constitutes the second reason for choosing MFworks. Whether the ordinary end-user shares this opinion with the author will depend on his or her familiarity with Tomlin's map algebra operators. With respect to these operators, MFworks offers the option to write scripts, thus assigning operations in the order of the user's preference, allowing a versatile set of operations to interact with each other, something that proved especially useful in calculating paths through time intervals and solving the multiple path problem (see 6.3).
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

39

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

6.2 Choice of data
The data chosen for this undertaking was a small dataset, in case of the Brown's Pond area only covering 13 km2, and in the case of the fictitious data merely 0.25 km2. In order to evaluate the networking capacities properly, in hindsight it seems more appropriate to have chosen a larger area, and also to have incorporated real-world data. The same applies to implementing travel cost. Here, purely fictitious data were randomly located. However, since the main task was to prove the feasibility of network analysis in GIS, the data used posed a satisfactory challenge, as it highlighted the necessary procedures for modelling the network and for solving the problems that occurred.

6.3 General accuracy
Using raster GIS for network analysis leads into a simplification of a complex network structure. The path is prone to be distorted, firstly, due to the mistaken length introduced by Incremental Length, and secondly, due the zigzagged path, a consequence of the innate grid structure. Nonetheless, a fine-tuned use of Incremental Linkage and a minimal cell resolution can have a smoothing effect on the exact delineation of the path. On the other hand, minimising cell resolution increases computation.

In raster GIS the precision of the model is determined by the cell resolution, the finer the resolution (the smaller the cell size), the better the precision. For this research a cell resolution of 20m was deemed appropriate for the task in question, as it would allow encompassing normal road width and adjacent areas within one cell width. For a dense inner city road network a cell resolution of 10m would be preferable, allowing even narrow blocks to be incorporated into the model.

6.4 Spread artefacts
The concept of adding proximity surfaces will some times lead to peculiar artefacts. A special case appears in a regular lattice if the cost surface is isotropic: Here the multiple path problem is clearly visible, since all possible paths per se have the same accumulated cost towards the destination. Here, human mind, as opposed to computer mind, would intuitively seek out a solution that implements a heuristic search, always following the path that yields the shortest Euclidian distance to the destination. More often occurs the so-called multiple path problem, particularly if the road network and the cost surface are oversimplified. There are no distinctive low values, so that in order to gain a coherent
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

40

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

route from start to destination so many low valued cells have to be selected that no clear path can be discerned (Figure 6-1).

Figure 6-1 a(left) and b(right): Typical "multiple optimal path"-artefact caused by oversimplification of network model and cost surface, (a) is a special case: all cells have the same cost value (homogeneous cost surface), thus there is no distinguishable lest cost path.

A solution to the first problem is to pass an algorithm over the multiple path image, which will retain the cells that are successively closest in Euclidian distance to the destination point, similar to the renown A*-algorithm. In practice, this means first, creating a layer with cell values equivalent to the Euclidian distance from cell to destination, and second, tracing the least cost path down this surface. Spreading from the destination point in a homogeneous surface with cost value 1, and then masking out the cells that are roads, achieves the first step of creating a Euclidean distance cost surface. The second step involves building proximity surfaces using the Euclidian Distance surface as cost surface, and then adding these surfaces to yield the least-cost path. As before, several low values may have to be selected to yield a coherent path (Figure 6-2). The result is not convincingly perfect for the special case, but a definite trend can be discerned.

Figure 6-2: Solving the multiple path problem in Fig 6-1 a and b, using Euclidean distance as cost surface

The reason for the imperfection of the left path lies in the generic structure of raster GIS. When building the Euclidean cost surface by spreading from the destination point, only those cells
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

41

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

that are directly in line with the eight directions will have the true distance, all other cells will have an approximated distance. A further step towards delineating the optimal path would be to create a cost surface with true Euclidean distance.

For the right path an optimal solution is clearly determinable, even when not using true Euclidean distance as cost surface.

To build a cost surface with true Euclidean distance, the following steps would have to be taken: 1. Export multiple path layers as XYZ file, edit in Visual Basic so that two files are created, XYX and XYY, containing the X-coordinates and Y-coordinates of the cells respectively. Re-import into MFworks 2. Create two layers with same extent and resolution as the multiple path layers, where all cell values are set to the X-coordinate and Y-coordinate respectively for the destination point. 3. Use Pythagoras to create a fifth layer, where the cell values are the true Euclidean distance between the cell and the destination point. Alternatively, instead of creating two layers with X and Y for the destination point, the coordinate values can be extracted as single values and used in a mathematical operation on the XYX and XYY layers directly.

Another method, setting Euclidean distance aside, is to use the multiple path surface as input cost surface, and trace the least cost path down this surface. This, of course, is only applicable to the multiple paths in Fig 6-1b.

In terms of algorithm, tracing the least-cost path may then be described as follows: 1. Follow the selected lowest values delineating the optimal path (fanning in many directions) from start to destination. 2. When a “junction” appears, spread out in a breadth-first search, for all paths p 1 to p n do the following: for all separate paths, compare p 1 cell n+1 with p 2 cell n+1 with … p n cell n+1, visit only cells that have not been visited before if all cell values are equal, repeat this step till the following occurs: if p n cell n+1 indicates a non-selected cell, terminate this path; if the cell values are unequal, keep the path with the lowest value;

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

42

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

terminate other paths; continue on this path till next junction and repeat step 2 3. Continue until destination.

The result of this algorithm applied to the path in Figure 6-1b is shown below:

Figure 6-3: Solving the multiple path problem in Fig 6-1(b) using the multiple path surface as cost surface

6.5 Continuously updated cost surface
In general, this approach may only be valid if there are no expected abrupt fluctuations in cost-ofpassage during the passage or if the length of passage is short enough not to be influenced by any fluctuations that could have occurred during the passage.

The method of using multiple surfaces for various cost-inducing variables would imply external Visual Basic or other applications for each of those variables. This is computationally viable, albeit not desirable. Multiple calculations and operations will have to interact at the same time, possibly causing errors.

Another option, an external database, holding all variables, which then transfers one calculated value only to a collapsed cost-of-passage surface, is computationally easier to implement. Bearing in mind the database-linking capabilities of Visual Basic, this option is preferable to the previous one using multiple cost variable surfaces.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

43

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

6.6 Time interval cost surface(s)
As was demonstrated earlier, using time intervals can lead to extensive computation. The more complex the network, and the more narrow the time intervals, the more iterative steps have to be computed. Given the fact that the network surface in raster GIS is a mere approximation rather than an exact model of a real-world network, it is questionable whether using time intervals necessarily will lead to better results in any case.

Further to this, average speed does not change abruptly and instantly at the borderline of two time intervals. It is a smooth transition, and consequently this must be reflected in calculating the overall cost of passage. Consequently, using time intervals demands a weighting of the successive time intervals to gain the appropriate time and speed for the overall route.

With reference to the above, here it seems appropriate to mention Horn (1999), who propounds an algorithm that calculates an approximation of shortest path travel time, independent of the particular navigation between nodes. Although his algorithm leans on graph theory and vector GIS, an implementation in a raster environment, being an approximation by it's own nature, could prove a fruitful ground for further research.

6.7 External Visual Basic application
The Visual basic application developed along with this research was designed with a particular task in mind, namely manipulating the attribute values of maps. The user-interface of this application is of course a first and simple version. As such, it performs the task it is set to do. Nonetheless, the Visual Basic application developed during the course of this research proved to be versatile and thus extendable to more than one function only, as it was also used in conjunction with deriving the Euclidean distance surfaces.

6.8 Meeting the objectives
The first objective was to prove the feasibility of network analysis in raster GIS, using Tomlin's map algebra operators. As this study has shown, and bearing in mind the limitations of raster GIS, particular with respect to curvature delineation and the requirement of a planar surface, this objective has been meet.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

44

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

The second objective was to develop a concept for calculating dynamic paths through a network, and has also been accomplished. Whether the concept utilised in this research is favourable over other approaches, is up to the reader to decide.

Finally, the custom-built application, which was originally intended as a task-specific application for network analysis only, was not achieved. This is mainly due to the author’s lack in Visual Basic skills. However, the procedures outlined in this paper, including the appendices and the Visual Basic application that has been developed, provide a total package, demonstrating the feasibility of network analysis in raster GIS and hopefully guiding they user towards the desired results, even without a custom-built application.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

45

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

7 Future developments
As one would expect in any explorative research, in addition to demonstrating known problems and facts, it also uncovers new possibilities for future improvements of existing models.

The feasibility of network analysis in raster GIS has been proved, but one main issue is still to be overcome: For a raster GIS to be able to adapt a fully functional network model, the question arises, is it possible to model over- and underpasses and crossing of lanes in raster GIS, and make raster GIS comparable to network analysis in vector GIS? Remembering Tomlin's directional constraints, the answer may lie in an extension of this concept, a model that incorporates more than the 8 nearest neighbours. Xu and Lathrop (1995) utilised such a model for a more exact delineation of the spread pattern, here it will be used for intercepting the flow at one cell and continuing it at a nonadjacent cell.

The Visual Basic application that was developed can serve as an example of how external programs can be linked with GIS software. For this particular software, it can also bee seen as a first step towards deployment of further extensions.

7.1 Modelling non-planar network features
One possible way of dealing with the question of modelling non-planar features is to extend Tomlin's 8 nearest neighbours to include the 24 nearest neighbours. Tomlin used the eight immediate neighbours, with identifying values ranging from 1 to 64 (20 to 27). This paper proposes to use the 24 nearest neighbours (20 to 223), as shown in figure 7-1.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

46

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Figure 7-1: Extending Tomlin's directional identifiers.

Overpasses and crossing of lanes can be modelled as shown in the following figure (Figure 7-2):

Figure 7-2: Modelling overpasses and crossing of lanes with the extended directional identifiers.

The cost of traversing the “skipped” cell will have to be calculated as a function of the 2 cells that are linked over the third cell. Normally one would assume this to be an average weighted value of the 2 linked cells. Obviously the cost-of-passage for this cell that appears in the presented surface can be related to one cell only, most naturally the cell in the line that passes over the other, or if there are multiple overpasses, the cell that represents a cell in the top layer. Based on these findings, it seems possible to model a non-planar network in the planar surface of raster GIS.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

47

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

In personal communication, Tomlin suggests an even more advanced method, using a lookup-table that indicates which cells are linked. Thus, it may appear possible to spread from any cell to any other cell, regardless of whether they are nearest neighbours or not. The coding for this algorithm would require some ingenuity, but the benefits are considerable, giving network analysis in raster much the same flexibility as already present in conventional vector GIS.

7.2 Application development
The Visual basic application developed along with this research was designed with a particular task in mind, namely manipulating the attribute values of maps. The user-interface of this application is of course a first and simple version. Future improvements may include more user parameters, such as searching for and updating specific values at designated locations.

During the course of this research it also has become clear that external interaction with a raster GIS map engine poses almost infinite possibilities. Consequently, it his hoped that this research might spark the development of further task-specific applications. In this respect, the Visual Basic application that was developed can serve as a first step towards the development of further extensions, such as creating a fully stand-alone MFcom application, a challenge that the author himself hopes to take up in the near future.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

48

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

8 Concluding remarks
This paper has delved into the realm of network analysis in raster GIS. Even though this was done using particular software, the concepts and conclusions presented are of general nature for any raster GIS.

Berry prefers the term surface analysis to the term network analysis, because "It seems humans are encapsulated in their autos and effectively constrained to the line work, but most other organisms and phenomena are of the "off-road" variety and see a continuum of movement possibilities." (Berry, 2000; personal communication). This supports Douglas’ emphasis on grid cells as sample points rather than direct neighbours. Applied in GIS world, a lateral thought line could be drawn from this to fuzzy set theory and geographical decision-making, and further on to operations research theories. As a matter of fact, transportation optimisation is an often-recurring feature in operations research literature such as Barceló (2000), or Hall (2000).

As has been discussed in this paper, network analysis in raster GIS approximates crisp linear features, and as such, to stay with the term of a continuous surface, network analysis in raster GIS is generically different from vector GIS. In all this one should remember that the seemingly clear results of any analysis in GIS should be taken as a guideline to be interpreted by human mind, and not as a finite and absolute answer. Inasmuch as these presumptions should be upheld for network analysis in general, it should also be a prerequisite for the second focus of this paper: time-dependency. Under such circumstances, meaning the approximation of the least-cost path dependent on cell resolution, Incremental Length error and zigzagging path delineation, the results from this research indicate fully that network analysis is viable in raster GIS. The question of accuracy and absolute correctness is always dependent on the model used.

As a final remark, after conducting his research, the author is inclined to follow suit in Berry's view of using raster GIS for representing a continuous surface rather than a finite network, thus bringing spatial context to the least-cost path problem, by explicitly visualising the circumstantial factors that affect the delineation of the path.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

49

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

9 Acknowledgements
Defying normal conventions about network analysis as the dominion of vector GIS, the investigation for this research has not been an easy task. The author wishes to express his sincere gratitude and appreciation to all those who in large or small, through sharing their personal views and ideas, contributed to the successful completion of this paper.

The following persons have been of particular assistance: Prof. P.F. Fisher and Dr. N.J.Tate, University of Leicester, UK; Prof. David H. Douglas, University of Gävle, Sweden; Dave McIlhagga, DMSolutions, Canada; Jayme Cousins, Greig Garland, Robert Gammon, and Mathew Lumsdon, Thinkspace Inc., Canada; J. Berry, Berry and Associates, USA; Prof. C.D. Tomlin, University of Pennsylvania, USA; Gaute Langaas, ScanGIT, Norway and Walter Collishonn, Universidade Federal do Rio Grande do Su, Brasil.

Finally, the greatest appreciation goes to the Greenwood Institute at the University of Leicester, which provided not only a part-time job, but also office space and excellent computing and printing facilities, without which the completion of this paper would not have been possible.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

50

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

10 References
Barcelo, J., 2000, Putting the RUSH back in rush hour. OR/MS Today, 27, 2, 36-40 Berry, J., 2000a, Analyzing Accumulation Surfaces, in: Map Analysis: Procedures and Applications in GIS Modelling. Berry and Associates // Spatial Informations Systems Inc, http://dev.pacificmeridian.com/basis2/MapAnalysis/Topic5/Topic5.htm Berry, J., 2000b, Analyzing In-Store Shopping Patterns, in: Map Analysis: Procedures and Applications in GIS Modelling. Berry and Associates // Spatial Informations Systems Inc, http://dev.pacificmeridian.com/basis2/MapAnalysis/Topic6/Topic6.htm Chabini, I., 1998, Discrete dynamic shortest path problems in transportation applications, Transportation Research Record, 1645 Chabini, I., 1997, A new algorithm for shortest paths in discrete dynamic networks, as presented at 8th IFAC/IFIP/IFORS Symposium on transportation systems, Tech Univ Crete, Greece, 1618 June 1997 Collischonn, W. and Pilar, J.V., 2000, A direction dependent least-cost-path algorithm for roads and canals. International Journal of Geographic Information Systems, 12, 491-508. Cooke, K.L. and Hasley E., 1966, The shortest route through a network with time-dependent intermodal transit times, Journal of Mathematical Analysis and Applications, 14, 493-498 Costa da, J.R., 1996, Assessing tourism potential: From words to numbers. In Raster Imagery in GIS, Onword Press Deo, N. and Pang, C.-Y., 1984, Shortest path algorithms: taxonomy and annotation. Networks, 14, 275-323 Dijkstra, E. W. (1959), A note on two problems in Connection with graphs, Numerische Mathematik, 1, 269-271 Dolan, A. and Aldous, J. ,1993, Introduction to Networks and Algorithms. Douglas, D.H.,1994,Least-cost Path in GIS Using an Accumulated Cost Surface and Slopelines. Cartographica, 31, 37-51 Douglas, D.H., 1999, Least cost path in GIS using an accumulated cost surface and slope lines http://www.hig.se/~dds/research/leastcos/cumcost4.htm Dreyfus, S.E., 1969, An appraisal of some shortest path algorithms. Operations Research, 17, 395412 Eastman, J.R., 1989, Pushbroom Algorithms for Calculating Distances in Raster Grids. Proceedings, AUTOCARTO 9, 288-297. Hall, R. W., 2000, The study of transportation is paved with science. OR/MS Today, 27, 4, 22-25
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

51

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Horn, M. E. T., 1999, Efficient modeling of travel in networks with time-varying link speeds, CSIRO Mathematical and Information Sciences Technical Report CMIS 99/97 http://www.cmis.csiro.au/Mark.Horn Husdal, J., Sandvik, A. and Klingsheim, A., 1998, PloGIS – et verktøy i forvaltning av bilpark og planlegging av kjørerute (Norwegian, English: PloGIS - a tool in car pool management and route planning), Coursework submitted in fulfillment of the one-year undergraduate study in GIS, Telemark College, Norway Husdal, J., 1999, Network Analysis - Raster versus Vector, A comparison study. Unpublished, coursework for the MSC in GIS, University of Leicester. http://husdal.com/mscgis/network.htm Husdal, J., 2000, An investigation into fastest path problems in dynamic transportation networks. Unpublished, coursework for the MSC in GIS, University of Leicester. http://husdal.com/mscgis/research.htm Jaga, R.M., Sundaram, A., Natarajan, T., 1993, Wasteland development using geographic information system techniques. International Journal of Remote Sensing, 14, pp. 32493257. Jones, C., 1997, Geographical Information Systems and Computer Cartography, Addison-Wesley Pub Co, 225-230 Limp, F. (2000), R-E-S-P-E-C-T. A review of raster GIS systems. GeoEurope, June 2000, http://www.geoplace.com/ge/2000/0600/0600rs.asp Lupien, A.E., Moreland, W.H. and Dangermond, J. (1987). Network analysis in geographic information systems. Photogrammetric Engineering and Remote Sensing, 53,1417-1421 McIlhagga, D., 1997, Optimal path delineation to multiple targets incorporating fixed cost distance. Unpublished, Honours Thesis for Bachelor of Arts, Carleton University. McIlhagga, D., 2000, Technological Impact on Route Planning of Optimal Solutions to the Multiple Target Access Problem. Unpublished, Slides presentation delivered at GIS 2000, Toronto, Canada, March 14th, 2000. Obtained through personal communication. Mitchell, J.S.B, and Kiersey, D.M., 1984, Planning strategic paths through variable terrain data. Applications of Artificial Intelligence, SPIE, 485, 172-179 Partyka, J.G., and Hall, R.W., 2000, On the road to service. OR/MS Today, 27, 4, 26-35 Thinkspace Inc., 2000, MFGuide. User manuals and tutorials for MFworks. http://www.thinkspace.com/OLH/MFguide/Contents/WhatsInMFg.pdf Tomlin, C. D., 1983, Digital Cartographic Modelling Techniques in Environmental Planning. Unpublished, doctoral dissertation, Yale University.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

52

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Tomlin, C.D., 1990, Geographic Information Systems and Cartographic Modelling, Prentice Hall, New Jersey Van Eck, J. R. and De Jong, T., 1990, Adapting data structures and algorithms for faster transport network computations. Proceedings of the 4th int. symposium on spatial data handling, 1, 295-304 Xu, J., and Lathrop, R.G, 1995, Improving simulation of spread phenomena in raster-based Geographic Information System. International Journal of Geographic Information Systems, 9, 154-168.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

53

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

11 Appendices
Appendix A - Network Analysis in MFworks, step by step Appendix B - Traversing time intervals Appendix C - Using the Visual Basic application

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

54

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Appendix A Network analysis in MFworks , step by step
MFworks scripting commands are supplied to illustrate the procedures involved.

Input
Brown's pond study area as shown left and below

The first step now is to extract the road network, based on the legend values.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

55

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Step 1
Extracting road network [new map] = Recode [old map] Assigning [new value] to [old value] ; roadsonecode = Recode map2 Assigning 1 to 21 1 to 22 ; The next step is to define start and end points for the path

Step 2
Defining start and end points for the path Use the drawing tool (pen) to assign a arbitrary value to the start and end points. The values must not be present in the map. In this case the value 998 has been chosen for the start and 997 for the end point, then use Recode to extract these as separate maps.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

56

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables [new map] = Recode [old map] Assigning [new value] to [old value] ; start = Recode roadsonecode Assigning 1 to 998 ;

[new map] = Recode [old map] Assigning [new value] to [old value] ; end = Recode roadsonecode Assigning 1 to 997 ;

Now we must infer the directional constraints of the network.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

57

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Step 3
Defining directions Use Incremental Linkage on the road network to establish links between all cells. [new map] = Incremental Linkage [old map] ; roads2inclink = Incremental Linkage roadsonecode ;

Then use Recode to assign corresponding directional values to the cells to create an out-of-network or into-network layer. [direction map] = Recode [Incremental Linkage map] Asssigning [direction value] to [linkage value] ; directionmod = Recode roads2inclink Assigning 128 to 1 Assigning 64 To 2 Assigning 32 To 3 Assigning 16To 4 Assigning 8 To 5 Assigning 4 To 6 Assigning 2 To 7 Assigning 1 To 8 […] Assigning 37 To 44 Assigning 90 To 45 Assigning 165 To 46 ; Next, the cost layer must be defined.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

58

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Step 4
Defining cost Manually assign the cell values by using the edit tool. Alternatively the values can be inferred from other map layers, i.e. road class, speed limit. [cost map] = [speed limit map] x cell resolution x calculation ; Next step: Creating proximity surfaces and adding them

Step 5
Finding the least-cost path Spread from start and end points to create proximity surfaces and add these. Retain the lowest values, so that they yield a coherent path. [spread from start] = Spread [start map] To [max value] (.00 indicating number of decimals) In [cost] or [value] Outof [out of network map] ; SpreadFromStart = Spread start To [max value] (.00 indicating number of decimals) In cost Outof directionsmod ;

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

59

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables [spread from end] = Spread [end map] To [max value] (.00 indicating number of decimals) In [cost] or [value] Outof [out of network map] ; SpreadFromEnd = Spread end To [max value] (.00 indicating number of decimals) In cost Outof directionsmod ;

[Least cost path map] = [spread from start map] + [spread from end map] ; ShortPath2mod = SpreadFromStart + SpreadFromEnd ;

Use Group values in Legend menu to group lowest values, then change colours to highlight the path The cell value shown is the least "cost" of this path, in whatever measurement we have chosen, time, fuel, money etc. We could end here, but wouldn't you like to know how long the path is?

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

60

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Step 6
Finding the length (of the least cost path) Separate the path, and apply Incremental Length. The cells will be assigned values indicating the length of the linear features x cell resolution in each cell. [path map] = Recode [added proximity surfaces] Assigning [new value] to [lowest values] ; ShortestPath = Recode ShortPath2mod Assigning 1 To 263 1 To 264 1 To 265 1 To 266 ; [length per cell map] = Incremental Length [path map] ; ShortestLength = IncrementalLength ShortestPath ;

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

61

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables [path length map] = Score [path map] By [cell length map] Total ; PathLength = Score ShortestPath By ShortestLength Total ; Finally, we can display the path on the initial map.

Step 7
Displaying the least cost path on a map Since the path map has VOID cells where there is no road, it can be laid over the initial map using the Cover operation. [final map] = Cover [map] With [path map] ; MapLayer5 = Cover map2 With ShortestPath ; For illustration purposes, the map colours have been changed.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

62

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Appendix B - Network analysis in MFworks, Traversing time intervals

Since the basic steps for traversing time intervals are the same as for calculating a path as shown in appendix A, only the differences will be highlighted here. Steps that are described in appendix A will not be reiterated here.

Defining start and end points for the path
After extracting the road network, a start and an endpoint for the path is selected; then the points are extracted into separate layers. Start: upper right, End: lower left

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

63

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Defining cost
Define the cost layers to be used in this calculation, here layer 1 and 2

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

64

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Find possible paths in first time interval
Spread from start till cut-off point (new time interval is reached); this will depend on when travel starts in the first time interval. Cut off (spread distance) = Time interval 2 begins minus Starting time of travel

Calculate all paths from cut-off points to destination, by spreading from cutoff points and destination points and adding the proximity surfaces. Path 1

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

65

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables Path 2

Path 3 The path with the lowest calculated value is the least-cost continuation from the related cut-off point, in this case path 2. The cost is found by adding the cell values of path to cut-off point and the continuing path with the lowest value.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

66

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Joining the separate time interval paths
First, separate the path from start to cut-off point by spreading from cutoff point in cost layer 1; add the proximity surfaces of this spreading with the first (till cut-off) and retain the lowest values.

Extract the path. Note the multiple paths problem. A solution to this is given in 6.3.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

67

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables Extract the next part of the path Note the "junction artefact". A solution to this is given in 5.3.2

Finding the final path
After correcting eventual artefacts, the final path can be found by adding the 2 layers together using the Cover operation. As in appendix A, the exact path length may be calculated and the path may be displayed on the general map for visualisation.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

68

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Appendix C - Using the Visual Basic Application
About the application
The Visual Basic application (xyzupdate.exe) is a standalone application for updating tab-delimited xyz-files, that have been exported from MFworks. The application supplied is an example application that updates the last columns in the xyz-file with random values. Other more advanced functions are possible, such as updating selected values, or updating with a specific value, dependent on various parameters. For this purpose the application is delivered with Visual Basic source files that can be edited in Microsoft Visual Basic.

Using the application
Start the xyzupdate.exe application. (Use Start Run and browse through the \vbp\app folder)

The application has 2 options: Update the file manually or Update continuously in time intervals.

Entering the input and output file name
Enter the full input pathname of the file you want to update. (here it will be d:\vbp\files\export.xyz) Enter the full output pathname of the file you want to update. It is recommended that you change the name for the output file to avoid corruption of the data.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

69

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Select mode of update
By selecting the Update button the file selected will be updated once. By setting a time interval the file be updated continuously. The time interval entered must be an integer value between 10 and 60.

Display
The application displays the values in the input file, and the values in the output file. The first column indicate the line position (row) in the output file.

Necessary preparations
The input file must be exported from MFworks in tab-delimited format as xyz-file.

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

70

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

Interface source code
For full documentation, open the application files in Microsoft Visual Studio/Visual Basic 'This application was developed for manipulating a tab-delimited xyz-file. 'Author: Jan Husdal URL: www.husdal.com email: jan@husdal.com 'In practical terms, the application reads the tab-delimited file line by line, 'creating text strings for each line and enters each line into a collection. 'The collection items (strings, file lines) are split into its components X, Y and Z, 'where the Z value is changed with a random value. 'The function of changing the Z value can be replaced by any desired function 'once the lines have been split. 'The application allows manual update or time interval update 'Time intervals should not be less than 10 seconds 'Too many time interval updates have caused this application to hault, 'but no apparent error has been found. '===================================================== 'Declare variables Dim listCount As Integer Dim strOpen As String Dim intFile As Integer Dim strLine As String Dim colOldFile As New Collection Dim colNewFile As New Collection Dim intCount As Integer Dim fileOpen As String ‘Timer Button Private Sub cmdTimer_Click() Dim I As Long ‘Initiate timer, set variables If tmrUpdate.Enabled = False Then I = (Abs(Int(txtsecs.Text)) * 1000) Debug.Print I tmrUpdate.Interval = I tmrUpdate.Enabled = True cmdTimer.Caption = "Stop Timer)" Else tmrUpdate.Enabled = False cmdTimer.Caption = "Start Timer" End If Exit Sub End Sub 'Update Button Private Sub cmdUpdate_Click() 'Clear read in/ read out windows lstFileIn.Clear lstFileOut.Clear
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

71

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables ' Declare variables for file input/output fileOpen = txtFileIn.Text fileOut = txtFileOut.Text 'Open file entered in textbox intFile = FreeFile Open fileOpen For Input As #intFile 'Add lines in file to collection colOldFile Do Until EOF(intFile) Line Input #intFile, strLine colOldFile.Add strLine Loop Close #intFile 'Loop through file, do changes, then export file For intCount = 1 To colOldFile.Count listCount = intCount colNewFile.Add ChangeData(colOldFile(intCount)) Next intCount Open fileOut For Output As #intFile For intCount = 1 To colNewFile.Count Print #intFile, colNewFile(intCount) Next intCount Close #intFile End Sub 'Function for changing cost attribute Function ChangeData(strLine As String) As String Dim intTab1 As Integer Dim intTab2 As Integer Dim strCol1 As String Dim strCol2 As String Dim strCol3 As String 'Split line into its three values, x y and z intTab1 = InStr(strLine, vbTab) intTab2 = InStr(intTab1 + 1, strLine, vbTab) strCol1 = Left(strLine, intTab1 - 1) strCol2 = Mid(strLine, intTab1, intTab2 - intTab1 - 1) strCol3 = Right(strLine, Len(strLine) - intTab2) 'Display import data in 'File read in, include line number as first value OldData = listCount & vbTab & strCol1 & vbTab & strCol2 & vbTab & strCol3 lstFileIn.AddItem OldData 'Change cost attributes, ignore data outside roads (value 99999) If strCol3 <> 999999 Then 'Ignore values not associated with roads strCol3 = Int(Rnd(1123) * 10) End If 'Concatenate values into one line ChangeData = strCol1 & strCol2 & vbTab & strCol3 'Display export data in 'File read out' ChangeDataDisplay = listCount & vbTab & strCol1 & vbTab & strCol2 & vbTab & strCol3 lstFileOut.AddItem ChangeDataDisplay End Function
Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

72

How to make a straight line square - Network analysis in raster GIS with time dependent cost variables

‘Timer function Private Sub tmrUpdate_Timer() 'Clear read in/ read out windows lstFileIn.Clear lstFileOut.Clear ' Declare variables for file input/output fileOpen = txtFileIn.Text fileOut = txtFileOut.Text 'Open file entered in textbox intFile = FreeFile Open fileOpen For Input As #intFile 'Add lines in file to collection colOldFile Do Until EOF(intFile) Line Input #intFile, strLine colOldFile.Add strLine Loop Close #intFile 'Loop through file, do changes, then export file For intCount = 1 To colOldFile.Count listCount = intCount colNewFile.Add ChangeData(colOldFile(intCount)) Next intCount Open fileOut For Output As #intFile For intCount = 1 To colNewFile.Count Print #intFile, colNewFile(intCount) Next intCount Close #intFile End Sub

Jan Husdal, MSc in GIS, University of Leicester, 1999-2000

73

Sign up to vote on this title
UsefulNot useful