ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • ArcGIS Pro
  • ArcMap
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

  • ArcGIS Pro
  • ArcMap
Esri
English
  • English
  • Deutsch
  • Español
  • Français
  • 日本語
  • Русский
  • 简体中文
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions
  • Tools
  • Tool reference
  • Spatial Analyst toolbox
  • Distance toolset
  • Back to Top
  • An overview of the Spatial Analyst toolbox
  • A complete listing of the Spatial Analyst tools
  • Analysis environments and Spatial Analyst
  • GPU processing with Spatial Analyst
  • Parallel processing with Spatial Analyst
  • Spatial Analyst toolbox licensing
  • Spatial Analyst toolbox history
  • Conditional toolset

    • An overview of the Conditional toolset
    • Con
    • Pick
    • Set Null
    • Conditional toolset concepts

    Density toolset

    • An overview of the Density toolset
    • Kernel Density
    • Line Density
    • Point Density
    • Density toolset concepts

    Distance toolset

    • An overview of the Distance toolset
    • Corridor
    • Cost Allocation
    • Cost Back Link
    • Cost Connectivity
    • Cost Distance
    • Cost Path
    • Cost Path As Polyline
    • Euclidean Allocation
    • Euclidean Back Direction
    • Euclidean Direction
    • Euclidean Distance
    • Path Distance
    • Path Distance Allocation
    • Path Distance Back Link
    • Distance toolset concepts

    Extraction toolset

    • An overview of the Extraction toolset
    • Extract by Attributes
    • Extract by Circle
    • Extract by Mask
    • Extract by Points
    • Extract by Polygon
    • Extract by Rectangle
    • Extract Multi Values to Points
    • Extract Values to Points
    • Sample
    • Extraction toolset concepts

    Generalization toolset

    • An overview of the Generalization toolset
    • Aggregate
    • Boundary Clean
    • Expand
    • Majority Filter
    • Nibble
    • Region Group
    • Shrink
    • Thin
    • Generalization toolset concepts

    Groundwater toolset

    • An overview of the Groundwater toolset
    • Darcy Flow
    • Darcy Velocity
    • Particle Track
    • Porous Puff
    • Groundwater toolset concepts

    Hydrology toolset

    • An overview of the Hydrology toolset
    • Basin
    • Fill
    • Flow Accumulation
    • Flow Direction
    • Flow Distance
    • Flow Length
    • Sink
    • Snap Pour Point
    • Stream Link
    • Stream Order
    • Stream to Feature
    • Watershed
    • Hydrology toolset concepts

    Interpolation toolset

    • An overview of the Interpolation toolset
    • IDW
    • Kriging
    • Natural Neighbor
    • Spline
    • Spline with Barriers
    • Topo to Raster
    • Topo to Raster by File
    • Trend
    • Interpolation toolset concepts

    Local toolset

    • An overview of the Local toolset
    • Cell Statistics
    • Combine
    • Equal To Frequency
    • Greater Than Frequency
    • Highest Position
    • Less Than Frequency
    • Lowest Position
    • Popularity
    • Rank
    • Local toolset concepts

    Map Algebra toolset

    • An overview of the Map Algebra toolset
    • Raster Calculator
    • Map Algebra toolset concepts

    Math toolset

    • An overview of the Math toolset
    • Bitwise
    • Logical
    • Trigonometric
    • Abs
    • Divide
    • Exp
    • Exp10
    • Exp2
    • Float
    • Int
    • Ln
    • Log10
    • Log2
    • Minus
    • Mod
    • Negate
    • Plus
    • Power
    • Round Down
    • Round Up
    • Square
    • Square Root
    • Times
    • General math toolset concepts

    Multivariate toolset

    • An overview of the Multivariate toolset
    • Band Collection Statistics
    • Class Probability
    • Create Signatures
    • Dendrogram
    • Edit Signatures
    • Iso Cluster
    • Iso Cluster Unsupervised Classification
    • Maximum Likelihood Classification
    • Principal Components
    • Multivariate toolset concepts

    Neighborhood toolset

    • An overview of the Neighborhood toolset
    • Block Statistics
    • Filter
    • Focal Flow
    • Focal Statistics
    • Line Statistics
    • Point Statistics
    • Neighborhood toolset concepts

    Overlay toolset

    • An overview of the Overlay toolset
    • Fuzzy Membership
    • Fuzzy Overlay
    • Locate Regions
    • Weighted Overlay
    • Weighted Sum
    • Overlay toolset concepts

    Raster Creation toolset

    • An overview of the Raster Creation toolset
    • Create Constant Raster
    • Create Normal Raster
    • Create Random Raster

    Reclass toolset

    • An overview of the Reclass toolset
    • Lookup
    • Reclass by ASCII File
    • Reclass by Table
    • Reclassify
    • Rescale by Function
    • Slice
    • Reclass toolset concepts

    Segmentation and Classification toolset

    • An overview of the Segmentation and Classification toolset
    • Classify Raster
    • Compute Confusion Matrix
    • Compute Segment Attributes
    • Create Accuracy Assessment Points
    • Export Training Data For Deep Learning
    • Generate Training Samples From Seed Points
    • Inspect Training Samples
    • Remove Raster Segment Tiling Artifacts
    • Segment Mean Shift
    • Train ISO Cluster Classifier
    • Train Maximum Likelihood Classifier
    • Train Random Trees Classifier
    • Train Support Vector Machine Classifier
    • Update Accuracy Assessment Points
    • Segmentation and Classification concepts

    Solar Radiation toolset

    • An overview of the Solar Radiation toolset
    • Area Solar Radiation
    • Points Solar Radiation
    • Solar Radiation Graphics
    • Solar Radiation toolset concepts

    Surface toolset

    • An overview of the Surface toolset
    • Aspect
    • Contour
    • Contour List
    • Contour with Barriers
    • Curvature
    • Cut Fill
    • Hillshade
    • Observer Points
    • Slope
    • Viewshed
    • Viewshed 2
    • Visibility
    • Surface toolset concepts

    Zonal toolset

    • An overview of the Zonal toolset
    • Tabulate Area
    • Zonal Fill
    • Zonal Geometry
    • Zonal Geometry as Table
    • Zonal Histogram
    • Zonal Statistics
    • Zonal Statistics as Table
    • Zonal toolset concepts

    Cost Connectivity

    ArcMap 10.8
    |
    Help archive
    ArcGIS Desktop is in mature support and will be retired March 1, 2026. There are no plans for future releases of ArcGIS Desktop, and it is recommended that you migrate to ArcGIS Pro. See Migrate from ArcMap to ArcGIS Pro for more information.

    Available with Spatial Analyst license.

    • Summary
    • Illustration
    • Usage
    • Syntax
    • Code sample
    • Environments
    • Licensing information

    Summary

    Produces the least-cost connectivity network between two or more input regions.

    Learn more about how the Cost Connectivity tool works

    Illustration

    Input and output from Cost Connectivity
    CostConnectivity(Regions, Cost_Ras, Cost_Connect)
    Input and output from Cost Connectivity
    The two inputs (regions and cost data) are shown on the left side of the image, and right side of the image shows the output least-cost network displayed over the regions.

    Usage

    • The input regions can be either raster or feature data.

    • In a raster, a region is a group of cells with the same value that are contiguous to one another (adjacent). When your input regions are identified by a raster, if any zones (cells with the same value) are composed of multiple regions, first run the Region Group tool as a preprocessing step to assign unique values to each region. Use the resulting raster as the input regions to the Cost Connectivity tool.

    • When input regions are identified by polygon, line, or point data, they are converted to raster using the feature ID to ensure the resulting regions have unique values. Therefore, multipart polygons cannot be input. When multipoint data is entered, Cost Connectivity randomly selects one of the points at the location as the region value.

      You can control the resolution of the rasterized input feature regions with the Cell Size environment. By default, the resolution will be set to the resolution of the input cost raster.

    • When using polygon feature data for the input region data, care must be taken with how the output cell size is handled when it is coarse, relative to the detail present in the input. The internal rasterization process employs the same default Cell assignment type method as the Polygon to Raster tool, which is CELL_CENTER. This means that data not located at the center of the cell will not be included in the intermediate rasterized region and so will not be represented in the distance calculations. For example, if your regions are a series of small polygons, such as building footprints that are small relative to the output cell size, it is possible that only a few of them will fall under the centers of the output raster cells, seemingly causing most of the others to be lost in the analysis.

      To avoid this situation, as an intermediate step, you could rasterize the input features directly with the Polygon to Raster tool, set a Priority field, and use the resulting output as input to the Cost Connectivity tool. Alternatively, you could select a small enough cell size to capture the appropriate amount of detail from the input features.

    • When the region input is a feature, the ObjectID field (for example, OID or FID, depending on the type of the feature input) will be used as the region identifier.

    • If the input regions are raster and the range of the row IDs is very large (even if there are only a few regions), the Cost Connectivity performance may be negatively impacted.

    • Cell locations with NoData in the Input cost raster act as barriers.

    • The default processing extent is the same as that of the Input cost raster.

    • The cost raster cannot contain values of zero since the algorithm is a multiplicative process. If your cost raster does contain values of zero, and these values represent areas of lowest cost, change values of zero to a small positive value (such as 0.01) before running Cost Connectivity, by first running the Con tool. If areas with a value of zero represent areas that should be excluded from the analysis, these values should be turned to NoData before running Cost Connectivity, by first running the Set Null tool.

    • For Output feature class of neighboring connections, the neighbors are not identified by Euclidean distance but instead are identified by cost distance. Therefore, a region's closest neighbor is the cheapest one to travel to, not the one that is closest in distance. A cost allocation operation is performed to identify which regions are neighbors to one another.

    • The optimum output network is created from the paths produced in the optional neighboring connections output. The paths in the optional neighboring connections output are converted to graph theory. The regions are the vertices, the paths are the edges, and the accumulative costs are the weights for the edges. The minimum spanning tree is calculated from the graph representation of the paths to determine the least-cost path network necessary to travel between the regions.

    • Each least-cost path first reaches the outer boundary of the polygon or multicell region. From the perimeter of the region, the tool then continues the paths with additional line segments, allowing for points of entry and exit between regions, and movement within them. There is no additional cost of movement along these line segments.

    • The Cost Distance and Cost Path tools can be used to connect regions that are not directly connected in the minimum spanning tree based on a priori information. For example, a particular region may need an alternative escape route for fire fighters to evacuate from the region. Since the resulting paths from Cost Path only reach the edge of a region, if you want to use these additional paths in the integrated network to perform subsequent network analysis, you will need to extend these paths within the region to connect them to the paths in the minimum spanning tree network.

    • The optional neighboring connections output can be used as an alternative network to the minimum spanning tree network. This output connects each region to its neighboring cost regions, thus producing a more complex network with many paths. The feature class can be used as is, or as the base from which to create your own desired network. To do that, you can select the specific paths you want within the network using the Select By Attributes tool in the Selection drop-down list, the Select Features tool on the Tools toolbar, or the Select geoprocessing tool. Deciding which paths to select can be based on knowledge of the area and the statistics associated with the paths in the resulting attribute table.

    • The resulting network, either from the minimum spanning tree or the optional neighboring connections, can be converted to a Network Analyst network to perform additional network analysis.

    • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

    Syntax

    CostConnectivity(in_regions, in_cost_raster, out_feature_class, {out_neighbor_paths})
    ParameterExplanationData Type
    in_regions

    The input regions that are to be connected by the least-cost network.

    Regions can be defined by either a raster or a feature dataset.

    If the region input is a raster, the regions are defined by groups of contiguous (adjacent) cells of the same value. Each region must be uniquely numbered. The cells that are not part of any region must be NoData. The raster type must be integer, and the values can be either positive or negative.

    If the region input is a feature dataset, it can be either polygons, lines, or points. Polygon feature regions cannot be composed of multipart polygons.

    Raster Layer; Feature Layer
    in_cost_raster

    A raster defining the impedance or cost to move planimetrically through each cell.

    The value at each cell location represents the cost-per-unit distance for moving through the cell. Each cell location value is multiplied by the cell resolution while also compensating for diagonal movement to obtain the total cost of passing through the cell.

    The values of the cost raster can be integer or floating point, but they cannot be negative or zero (you cannot have a negative or zero cost).

    Raster Layer
    out_feature_class

    The output polyline feature class of the optimum (least-cost) network of paths necessary to connect each of the input regions.

    Each path (or line) is uniquely numbered, and additional fields in the attribute table store specific information about the path. Those fields include the following:

    • PATHID—Unique identifier for the path
    • PATHCOST—Total accumulative cost for the path
    • REGION1—The first region the path connects
    • REGION2—The other region the path connects

    This information provides you insight into the paths within the network.

    Since each path is represented by a unique line, there will be multiple lines in locations where paths travel the same route.

    Feature Class
    out_neighbor_paths
    (Optional)

    The output polyline feature class identifying all paths from each region to each of its closest-cost neighbors.

    Each path (or line) is uniquely numbered, and additional fields in the attribute table store specific information about the path. Those fields include the following:

    • PATHID—Unique identifier for the path
    • PATHCOST—Total accumulative cost for the path
    • REGION1—The first region the path connects
    • REGION2—The other region the path connects

    This information provides you insight into the paths within the network and is particularly useful when deciding which paths should be removed if necessary.

    Since each path is represented by a unique line, there will be multiple lines in locations where paths travel the same route.

    Feature Class

    Code sample

    CostConnectivity example 1 (Python window)

    The following Python window script demonstrates how to use the CostConnectivity tool.

    import arcpy
    from arcpy import env
    from arcpy.sa import *
    env.workspace = "C:/sapyexamples/data"
    CostConnectivity("regions.shp", "cost_ras", "C:/sapyexamples/output/costnetwork", "C:/sapyexamples/output/costneigh")
    
    CostConnectivity example 2 (stand-alone script)

    Produces the least-cost optimum network of paths connecting the input regions to one another.

    # Name: CostConnectivity_Ex_02.py
    # Description: Calculates the least-cost network
    # Requirements: Spatial Analyst Extension
    
    # Import system modules
    import arcpy
    from arcpy import env
    from arcpy.sa import *
    
    # Set environment settings
    env.workspace = "C:/sapyexamples/data"
    
    # Set local variables
    inRegionData = "regions.shp"
    inCostRaster = "cost_ras"
    outCostNetwork = "C:/sapyexamples/output/costnetwork"
    outOptCostNeigh = "C:/sapyexamples/output/costneigh"
    
    # Check out the ArcGIS Spatial Analyst extension license
    arcpy.CheckOutExtension("Spatial")
    
    # Execute Cost Connectivity
    CostConnectivity(inRegionData, inCostRaster, outCostNetwork, outOptCostNeigh)
    

    Environments

    • Auto Commit
    • Cell Size
    • Cell Size Projection Method
    • Current Workspace
    • Default Output Z Value
    • Extent
    • Geographic Transformations
    • Mask
    • M Resolution
    • M Tolerance
    • Maintain Spatial Index
    • Output CONFIG Keyword
    • Output Coordinate System
    • Output has M values
    • Output has Z values
    • Output M Domain
    • Output XY Domain
    • Output Z Domain
    • Scratch Workspace
    • Snap Raster
    • XY Resolution
    • XY Tolerance
    • Z Resolution
    • Z Tolerance

    Licensing information

    • Basic: Requires Spatial Analyst
    • Standard: Requires Spatial Analyst
    • Advanced: Requires Spatial Analyst

    Related topics

    • An overview of the Distance toolset
    • Understanding cost distance analysis

    ArcGIS Desktop

    • Home
    • ArcGIS Pro
    • ArcMap
    • 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