ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Analytics

  • Home
  • Applied Analysis
  • Python

Cost distance analysis workflow using ArcGIS Desktop - Lesson 3: Creating a least-cost path

    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:

    1. Calculate the cost distance and backlink rasters from a source using the Cost Distance tool.
    2. Determine the least-cost path from a source to a destination using the Cost Path tool.

    This lesson is divided into three sections:

    1. Opening and editing the ModelBuilder model
    2. Using the Cost Distance tool to calculate cost distance and cost backlink rasters
    3. Using the Cost Path tool to calculate a least-cost path

    ArcGIS Spatial Analyst extension 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

    1. Open the LeastCostPath map document in the CostDistanceAnalysis folder by double-clicking the file.

      Opening the LeastCostPath.mxd

    2. 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.

      Source and Destination layers displayed on the CostSurface layer

    3. 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 Catalog in the taskbar, which will open the Catalog window. From the Catalog window, open the LeastCostPath model by right-clicking the model and clicking Edit.

      Opening the LeastCostPath.ModelBuilder model

    4. 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.

      Adding the Source layer into the ModelBuilder model

    5. 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.

      Adding the CostSurface layer into the ModelBuilder 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.

    1. To calculate accumulative cost distance from the source location, use the Cost Distance tool. This tool requires the ArcGIS Spatial Analyst extension 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 extension checkbox to turn it on.

      Browsing to the Extensions dialog box

      Checking the Spatial Analyst extension

    2. Once the extension is turned on, access is granted to the ArcGIS Spatial Analyst extension tools. Click the ArcToolbox button ArcToolbox in the Standard toolbar. Browse to the Cost Distance tool in the Distance toolset in the Spatial Analyst Tools toolbox.

      Browsing to the Cost Distance tool

    3. Drag the Cost Distance tool into the LeastCostPath model and place it to the right of the Source and CostSurface layers.

      Adding the Cost Distance tool to the ModelBuilder model

    4. Using the Connect tool Connect 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.

      Connecting the Source layer to the Cost Distance tool as the Input raster or feature source data.

    5. With the Connect tool still turned on, connect the CostSurface layer to the Cost Distance tool. Choose the Input cost raster option.

      Connecting the CostSurface layer to the Cost Distance tool as the Input cost raster

    6. 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

      Cost Distance tool dialog box with input parameters specified

    7. Click OK to close the Cost Distance tool's dialog box.
    8. Once the dialog box is closed, right-click the Cost Distance tool and click Run to execute the tool.

      Running the Cost Distance tool within the model

    9. 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.

      Adding the results from Cost Distance to the display

    10. 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.

      Source and Destination layers displayed on top of the cost distance layer

    11. 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.

      Source and Destination layers displayed on top of the backlink layer

    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.

    1. Click the ArcToolbox button ArcToolbox in the Standard toolbar. Browse to the Cost Path tool in the Distance toolset in the Spatial Analyst Tools toolbox.

      Browsing to the Cost Path tool

    2. Drag the Cost Path tool into the LeastCostPath model, and place it to the right of the CostDistance layer.

      Adding the Cost Path tool to the ModelBuilder model

    3. 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.

      Adding the Destination layer to the ModelBuilder model

    4. Using the Connect tool Connect 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.

      Connecting the Destination layer to the Cost Path tool as the Input raster or feature destination data

    5. Next, use the Connect tool to add the CostDistance layer to the Cost Path tool. Choose the Input cost distance raster option.

      Connecting the CostDistance layer to the Cost Path tool as the Input cost distance raster

    6. 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.

      Connecting the Backlink layer to the Cost Path tool as the Input cost backlink raster

    7. 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.

      Cost Path tool dialog box with input parameters specified

    8. Click OK to close the dialog box and apply the changes made to the Cost Path tool.
    9. Once the dialog box is closed, right-click the Cost Path tool and click Run to execute the tool.

      Running the Cost Path tool within the model

    10. Add the LeastCostPath output layer to the map document by right-clicking the green LeastCostPath layer in the model and clicking Add To Display.

      Adding the results from the Cost Path tool to the display

    11. Save the LeastCostPath model by clicking the Save button Save in the ModelBuilder taskbar. Close the model once it is saved.
    12. Zoom in on the least-cost path using the Zoom In tool Zoom In 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.

      Least-cost path connecting the source and destination displayed over the cost surface

    13. Save the map document by clicking the Save button Save 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.

    ArcGIS Desktop

    • Home
    • Documentation
    • Support

    ArcGIS

    • ArcGIS Online
    • ArcGIS Desktop
    • ArcGIS Enterprise
    • ArcGIS
    • ArcGIS Developer
    • ArcGIS Solutions
    • ArcGIS Marketplace

    About Esri

    • About Us
    • Careers
    • Esri Blog
    • User Conference
    • Developer Summit
    Esri
    Tell us what you think.
    Copyright © 2021 Esri. | Privacy | Legal