.TH r.cost 1 "" "" "" "" .PP .PP .br .SH NAME .PP \*Lr.cost\*O - 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. .br (GRASS Raster Program) .SH SYNOPSIS .PP \*Lr.cost\*O .br \*Lr.cost help\*O \*Lr.cost\*O [\*L-vkn\*O] \*Linput=\*Oname [\*Lstart_sites=\*Oname] [\*Lcoordinate=\*Ox,...]] [\*Lstop_coordinate=\*Ox,...]] [\*Lmax_cost=\*O\*Wcost\*O] [\*Lnull_value=\*Ovalue] .SH DESCRIPTION .PP r.cost determines the cumulative cost of moving to each cell on a cost surface (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. The output map will be of the same data format than the input map, integer or floating point. .SH OPTIONS .PP 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: .PP \*Lr.cost\*O [\*L-vkn\*O] \*Linput=\*Oname [\*Lstart_sites=\*Oname] [\*Lcoordinate=\*Ox,...]] [\*Lstop_coordinate=\*Ox,...]] [\*Lmax_cost=\*O\*Wmaxcost\*O] [\*Lnull_value=\*Ovalue] .PP .br .PP where the input name is the name of a raster map layer representing the cost surface map, the output name is the name of a raster map layer of cumulative cost, and each x coordinate pair gives the geographic location of a point from which the transportation cost should be figured. These starting points could be read from a sites file through the \*Lstart_sites= option. \*Wr.cost\*O will stop cummulating costs when either \*Wmaxcost\*O is reached, or one of the stop points given with the \*Lstop_coordinates=\*Ox,y is reached. Alternatelly, the stop points can be read from a site file through the \*Lstop_sites= option. Both points read from a site file and those given o the command line will be processd. The null cells in the input map can be assigned a (positive floating point) cost with the null_value .PP Alternately, the user can simply type \*Lr.cost\*O on the command line, without program arguments. In this case, the user will be prompted for parameter values using the standard GRASS \*Lparser\*O interface. .PP 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 or site file. In lieu of these coordinates, the output map (e.g., \*Loutput\*O) is presumed to contain starting points. All non-zero cells are considered to be starting points. \*LBeware:\*O doing this will overwrite \*Loutput\*O with the results of the calculations. If \*Loutput\*O does exist and points are also given on the command line or through a site file, the \*Loutput\*O file is ignored. .SH Flags: .PP \*L-v\*O .PP Processing is tracked verbosely. This program can run for a very long time. .PP \*L-k\*O .PP 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 \*L-k\*O option, the neighbors marked with a K are also considered. \*C .DS . . . . . . . . . . . . . . . . . . K . . K . . . . . . . . . . . . . . . . . . . . K . X . X . X . K . . . . . . . . . . . . . . . . . . . . X . O . X . . . . . . . . . . . . . . . . . . . . K . X . X . X . K . . . . . . . . . . . . . . . . . . . . K . . K . . . . . . . . . . . . . . . . . . .DE \*O.PP \*L-n\*O .PP When input map null cells are given a cost with the \*Lnull_value\*O option, the corresponding cells in the output map are no longer null cells. With this option, the null cells of the input map are retained as null cells in the output map. .PP Parameters: .PP \*Linput=\*Oname .PP Name of input raster map layer whose category values represent surface cost. .PP \*Loutput=\*Oname .PP 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. .PP \*Lstart_sites=\*Oname .PP name is the name of a site file that holds the coordinates of starting points from wich the transportation cost should be figured. .PP \*Lstop_sites=\*Oname .PP name is the name of a site file that hold the coordinates of stopping points. During execution, once the cumulative cost to all stopping points has been determined, processing stops. .PP \*Lcoordinate=\*Ox,...] .PP 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. .PP \*Lstop_coordinate=\*Ox,...] .PP 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. .PP \*Lmax_cost=\*O\*Wmaxcost\*O .PP This is the cost limit that forces \*Lr.cost\*O to restart the current point to be considered a stop point. .PP \*Lnull_value=\*O\*Wvalue\*O .PP The optional value that will be assigned to the null cells in the input map. This is a positive floating point value. .SH EXAMPLE .PP Consider the following example: \*C .DS Input: COST SURFACE . . . . . . . . . . . . . . . . 2 . 2 . 1 . 1 . 5 . 5 . 5 . . . . . . . . . . . . . . . . . 2 . 2 . 8 . 8 . 5 . 2 . 1 . . . . . . . . . . . . . . . . . 7 . 1 . 1 . 8 . 2 . 2 . 2 . . . . . . . . . . . . . . . . . 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .DE \*O.PP The user-provided ending location in the above example is the boxed \*L3\*O 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 (\*L-k\*O) 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 can be used as inputs to \*Lr.drain\*O, in order to trace the least-cost path given in this model between any given cell and the r.cost starting location(s). The two programs, when used together, generate least-cost paths or corridors between any two map locations (cells). .SH NULL CELLS .PP By defaults, null cells in the input raster map are excluded from the algorithm, and thus retained on output. .PP If one wants \*Lr.cost\*O to transparently cross the null cells, one must use the option \*Lnull_value=\*O\*W0.0\*O\*L. \*OThen, null cells just propagate adjacent costs. These cells could then be retained as null cells into the output map through the \*L-n\*O flag. .SH NOTES .PP If you submit the starting point map on the command line by specifying: .PP \*Loutput=start_pt_map\*O .PP the starting point map will be overwritten by the calculated output. It is wise to copy or rename (e.g., using \*Lg.copy\*O or \*Lg.rename\*O) the map of starting points to another name before submitting it to r.cost; otherwise, its contents will be overwritten. .PP Sometimes, when the differences among \*Linteger\*O cell category values the r.cost cumulative cost surface output are small, this cumulative cost output cannot accurately be used as input to \*Lr.drain\*O (\*Lr.drain\*O will output bad results). This problem can be circumvented by making the differences between cell category values in the cumulative cost output bigger. It is recommended that, if the output from r.cost is to be used as input to \*Lr.drain\*O, the user multiply the input cost surface map to r.cost by the value of the map's cell resolution, before running r.cost. This can be done using \*Lr.mapcalc\*O or other programs. The map resolution can be found using \*Lg.region\*O. This problem doesn't arise with floating point maps. .SH SEE ALSO .PP \*Lparser\*O .SH AUTHOR .PP Antony Awaida, .br Intelligent Engineering Systems Laboratory, .br M.I.T.U.S.Army Construction Engineering Research Laboratory .PP Updated for Grass 5 .br Pierre de Mouveaux (pmx@audiovu.com)