In lessons 1 and 2 of the cost-distance analysis workflows, a cost surface and an optimal connectivity network were created. Although a cost surface is necessary for all cost-distance analysis workflows, creating a network of paths may not be the goal of your project. In this lesson, you will walk through the second cost-distance analysis workflow. You will connect two specific regions with the optimum least-cost path.
Determining the least-cost path between a source and a destination is a two step process:
- Calculate the cost distance and backlink rasters from a source using the Cost Distance tool.
- Determine the least-cost path from a source to a destination using the Cost Path tool.
This lesson is divided into three sections:
- Opening and editing the ModelBuilder model
- Using the Cost Distance tool to calculate cost distance and cost backlink rasters
- Using the Cost Path tool to calculate a least-cost path
ArcGIS Spatial Analyst is required for this analysis and you must ensure that it is enabled. See Enabling the Spatial Analyst extension.
This lesson continues on the data that you downloaded in lesson 1. If you have not downloaded the data, see the first section in Lesson 1: Creating a cost surface.
Opening and editing the ModelBuilder model
- Open the LeastCostPath map document in the CostDistanceAnalysis folder by double-clicking the file.
- Three layers are visible on the map: the Source, Destination, and CostSurface. Each of these layers represents one of the three key components necessary for creating a least-cost path.
- To help keep the workflow organized, you will keep track of the tools you use in a ModelBuilder model. Within the CostDistanceAnalysis folder is a folder named Toolboxes, with a toolbox named CostDistanceAnalysisToolbox.tbx, which contains several models. One of these models will be used to create a least-cost path. Open ArcCatalog by clicking the ArcCatalog icon in the taskbar, which will open the Окно Каталог (Catalog). From the Окно Каталог (Catalog), open the LeastCostPath model by right-clicking the model and clicking Edit.
- All least-cost paths originate from an identified source, represented in this lesson by the Source layer. Drag the Source layer from the table of contents into the LeastCostPath model.
- Just as a source is required for all cost-distance analysis workflows, so is a cost surface. A cost surface indicates how costly, or taxing, it is to traverse each map unit. The least-cost path will find the route between a source and a destination which has the lowest amount of accumulative cost. Drag the CostSurface layer from the table of contents into the LeastCostPath model.
Using the Cost Distance tool to calculate cost distance and cost backlink rasters
As mentioned in the previous step, a least-cost path is the optimum route between two locations that exhibits the smallest accumulative cost. Remember, determining the least-cost path is a two step process. First you must calculate the cost distance and backlink rasters from the source over the cost surface.
- To calculate accumulative cost distance from the source location, use the Cost Distance tool. This tool requires the ArcGIS Spatial Analyst extension, so first make sure the extension is turned on by clicking the Customize tab in the ArcMap taskbar. Choose the Extensions option from the drop-down list, and check the ArcGIS Spatial Analyst checkbox to turn it on.
- Once the extension is turned on, access is granted to the ArcGIS Spatial Analyst tools. Click the ArcToolbox button in the Standard toolbar. Browse to the Cost Distance tool in the Distance toolset in the Spatial Analyst Tools toolbox.
- Drag the Cost Distance tool into the LeastCostPath model and place it to the right of the Source and CostSurface layers.
- Using the Connect tool in the LeastCostPath ModelBuilder model taskbar, connect the Source layer to the Cost Distance tool. Make the connection by clicking the Source layer first, and then click the Cost Distance tool. Choose the Input raster or feature source data option.
- With the Connect tool still turned on, connect the CostSurface layer to the Cost Distance tool. Choose the Input cost raster option.
- Double-click the Cost Distance tool to open the tool's dialog box. Type CostDistance in the Output distance raster parameter to name the output distance raster. The model automatically saves the file into the Output.gdb geodatabase file. Also type Backlink into the Output backlink raster parameter to create and save a backlink raster when the cost distance tool is run. The backlink raster indicates the direction from each cell to the neighboring cell with the lowest accumulative cost value. Both the accumulative cost and backlink rasters are necessary for creating a least-cost path. To summarize the input and output layers for the Cost Distance tool, specify the parameters as follows:
- Input raster or feature source data: Source
- Input cost raster: CostSurface
- Output distance raster: CostDistance
- Output backlink raster: Backlink
- Click OK to close the Cost Distance tool's dialog box.
- Once the dialog box is closed, right-click the Cost Distance tool and click Run to execute the tool.
- Add the CostDistance output layer to the map document by right-clicking the green CostDistance layer in the model and clicking Add To Display. Follow the same steps to add the Backlink layer to the display.
- Explore the CostDistance layer within the LeastCostPath map document. Turn off the Backlink layer in the table of contents so the CostDistance layer beneath is visible on the map. According to the legend, locations that can be reached at low costs from the source are in lighter colors. In contrast, locations farther from the source are more costly to reach, which is indicated by darker colors.
- Explore the Backlink layer within the LeastCostPath map document. Check the Backlink layer on in the table of contents so the CostDistance layer beneath is no longer visible on the map. According to the legend, each color represents the direction towards the neighboring cell with the least accumulative cost.
Using the Cost Path tool to calculate a least-cost path
At this point in the workflow, each location's accumulative cost and its backlink have been created. The final step uses the Cost Path tool to calculated the least-cost path from a source to the destination using the cost distance and backlink rasters calculated above.
- Click the ArcToolbox button in the Standard toolbar. Browse to the Cost Path tool in the Distance toolset in the Spatial Analyst Tools toolbox.
- Drag the Cost Path tool into the LeastCostPath model, and place it to the right of the CostDistance layer.
- Recall that a destination is one of the three necessary components for calculating a least-cost path. Drag the Destination layer from the table of contents into the LeastCostPath model and place it above the CostDistance layer.
- Using the Connect tool in the LeastCostPath ModelBuilder model taskbar, connect the Destination layer to the Cost Path tool. Make the connection by clicking the Destination layer first, and click the Cost Path tool. Choose the Input raster or feature destination data option.
- Next, use the Connect tool to add the CostDistance layer to the Cost Path tool. Choose the Input cost distance raster option.
- Using the same method in the previous two steps, connect the Backlink layer to the Cost Path tool, this time choosing the Input cost backlink raster option.
- Double-click the Cost Path tool within the LeastCostPath model to open the tool's dialog box. Type LeastCostPath in the Output raster parameter to name the resulting least-cost path. The model automatically saves it into the Output.gdb geodatabase. To summarize the input and output for the Cost Path tool, specify the parameters as follows:
- Input raster or feature destination data: Destination
- Destination field: ID
- Input cost raster: CostDistance
- Input cost backlink raster: Backlink
- Output raster: LeastCostPath
- Path type: BEST_SINGLE
Selecting the BEST_SINGLE path type will calculate the least-costly route between the source and destination. For additional information on the different path types see the Cost Path tool documentation.
- Click OK to close the dialog box and apply the changes made to the Cost Path tool.
- Once the dialog box is closed, right-click the Cost Path tool and click Run to execute the tool.
- Add the LeastCostPath output layer to the map document by right-clicking the green LeastCostPath layer in the model and clicking Add To Display.
- Save the LeastCostPath model by clicking the Save button in the ModelBuilder taskbar. Close the model once it is saved.
- Zoom in on the least-cost path using the Zoom In tool in the Tools toolbar. With the Zoom In tool selected, drag a rectangle in the area between the source and destination regions. Turn off the Backlink and CostDistance layers to make the least-cost path more visible.
- Save the map document by clicking the Save button on the Standard toolbar before closing out of the LeastCostPath ArcMap document.
Congratulations! At this point, the workflow for creating a least-cost path between two specified regions has been completed. One of the important take-away messages from this lesson is that three datasets are necessary for creating a least-cost path between two known locations: a source, a cost surface, and a destination. In Lesson 4: Creating a corridor, instead of creating a path between the source and destination, you will create a corridor between them.