r.cost
GRASS Reference Manual
r.cost NAME r.cost - Outputs a raster map layer showing the cumulative cost of moving between different geographic locations on an input raster map layer whose cell category values represent cost. (GRASS Raster Program) SYNOPSIS r.cost r.cost help r.cost [-vk] input=name [coordinate=x,...]] [stop_coordinate=x] DESCRIPTION r.cost (the input raster map layer) from other user- specified cell(s) whose locations are specified by their geographic coordinate(s). Each cell in the original cost surface map will contain a category value which represents the cost of traversing that cell. r.cost will produce an output raster map layer in which each cell contains the lowest total cost of traversing the space between each cell and the user-specified points. (Diagonal costs are multiplied by a factor that depends on the dimensions of the cell.) This program uses the current geographic region settings. OPTIONS r.cost can be run either non-interactively or interactively. The program will be run non-interactively if the user specifies the names of raster map layers and any desired options on the command line, using the form: r.cost [-vk] input=name output=name [coordinate=x,...]] [stop_coordinate=x,...]] where the input name coordinate pair gives the geographic location of a point from which the transportation cost should be figured. Alternately, the user can simply type r.cost on the command line, without program arguments. In this case, the user will be prompted for parameter values using the standard GRASS parser interface. r.cost can be run with two different methods of identifying the starting point(s). One or more points (geographic coordinate pairs) can be provided on the command line. In lieu of command line coordinates, the output map (e.g., output) is presumed to contain starting points. All non- zero cells are considered to be starting points. Beware: doing this will overwrite output with the results of the calculations. If output does exist and points are also given on the command line, the output is ignored and the coordinates given on the command line are used instead. GRASS 5.0beta6 GRASS Development Team 1 r.cost
GRASS Reference Manual
r.cost Flags: Processing is tracked verbosely. This program can run for a very long time. The Knight's move is used which improves the accuracy of the output. In the diagram below, the center location (O) represents a grid cell from which cumulative distances are calculated. Those neighbors marked with an X are always considered for cumulative cost updates. With the -k option, the neighbors marked with a K are also considered. . . . . . . . . . . . . . . . . . . K . . K . . . . . . . . . . . . . . . . . . . . K . X . X . X . K . . . . . . . . . . . . . . . . . . . . X . O . X . . . . . . . . . . . . . . . . . . . . K . X . X . X . K . . . . . . . . . . . . . . . . . . . . K . . K . . . . . . . . . . . . . . . . . . Parameters: Name of input raster map layer whose category values represent surface cost. Name of raster map layer to contain output. Also can be used as the map layer of the input starting points. If so used, the input starting point map will be overwritten by the output. Each x,y coordinate pair gives the easting and northing (respectively) geographic coordinates of a starting point from which to figure cumulative transportation costs for each cell. As many points as desired can be entered by the user. Each x,y coordinate pair gives the easting and northing (respectively) geographic coordinates of a stopping point. During execution, once the cumulative cost to all stopping points has been determined, processing stops. As many points as desired can be entered by the user. An optional maximum cumulative cost. EXAMPLE Consider the following example: Input: COST SURFACE . . . . . . . . . . . . . . . . 2 . 2 . 1 . 1 . 5 . 5 . 5 . . . . . . . . . . . . . . . . . 2 . 2 . 8 . 8 . 5 . 2 . 1 . . . . . . . . . . . . . . . . . 7 . 1 . 1 . 8 . 2 . 2 . 2 . . . . . . . . . . . . . . . . 2 GRASS Development Team GRASS 5.0beta6 r.cost
GRASS Reference Manual
r.cost . 8 . 7 . 8 . 8 . 8 . 8 . 5 . . . . . . . . . . . _____ . . . 8 . 8 . 1 . 1 . 5 | 3 | 9 . . . . . . . . . . . |___| . . . 8 . 1 . 1 . 2 . 5 . 3 . 9 . . . . . . . . . . . . . . . . Output (using -k): Output (not using -k): COST SURFACE CUMULATIVE COST SURFACE . . . . . . . . . . . . . . . . . . . * * * * * . . . . . . . 21. 21. 20. 19. 17. 15. 14. . 22. 21* 21* 20* 17. 15. 14. . . . . . . . . . . . . . . . . . . . * * * * * . . . . . . . 20. 19. 22. 19. 15. 12. 11. . 20. 19. 22* 20* 15. 12. 11. . . . . . . . . . . . . . . . . . . . . . * * * * * . . . . . 22. 18. 17. 17. 12. 11. 9. . 22. 18. 17* 18* 13* 11. 9. . . . . . . . . . . . . . . . . . . . . . * * * * * . . . . . 21. 14. 13. 12. 8. 6. 6. . 21. 14. 13. 12. 8. 6. 6. . . . . . . . . . . _____ . . . . . . . . . . . . . . . . . . 16. 13. 8. 7. 4| 0| 6. . 16. 13. 8. 7 . 4. 0. 6. . . . . . . . . . . |___| . . . . . . . . . . . . . . . . . . 14. 9. 8. 9. 6. 3. 8. . 14. 9. 8. 9 . 6. 3. 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The user-provided ending location in the above example is the boxed 3 in the left-hand map. The costs in the output map represent the total cost of moving from each box ("cell") to one or more (here, only one) starting location(s). Cells surrounded by asterisks are those that are different between operations using and not using the Knight's move (-k) option. This output map can be viewed, for example, as an elevation model in which the starting location(s) is/are the lowest point(s). Outputs from r.cost starting location(s). The two programs, when used together, generate least-cost paths or corridors between any two map locations (cells). NOTES If you submit the starting point map on the command line by specifying: output=start_pt_map the starting point map will GRASS 5.0beta6 GRASS Development Team 3 r.cost
GRASS Reference Manual
r.cost be overwritten by the calculated output. It is wise to copy or rename (e.g., using g.rename; otherwise, its contents will be overwritten. Sometimes, when the differences among cell category values in the r.cost is to be used as input to r.drain by the value of the map's cell resolution, before running r.cost or other programs. The map resolution can be found using g.region. SEE ALSO parser AUTHOR Antony Awaida, Intelligent Engineering Systems Laboratory, M.I.T. James Westervelt, U.S.Army Construction Engineering Research Laboratory 4 GRASS Development Team GRASS 5.0beta6