Build Network (Network Analyst)

Summary

Reconstructs the network connectivity and attribute information of a network dataset. The network dataset must be rebuilt after edits are made to the attributes or the features of a participating source feature class. After the source features are edited, the tool establishes the network connectivity only in the areas that have been edited to speed up the build process; however, when the network attributes are edited, the entire extent of the network dataset is rebuilt. This may be a slow operation on a large network dataset.

Learn more about which network dataset edits require a rebuild

Usage

  • If build errors are encountered when building the network, a warning message appears. Review and address these errors, as they indicate potential problems that may prevent the network from working as intended.

    Learn more about network build errors

  • Before building a network dataset, an exclusive schema lock is required on the network dataset and the participating source feature classes. This means that no one can be editing the participating feature classes. An error will occur if an exclusive schema lock cannot be obtained.

Parameters

LabelExplanationData Type
Input Network Dataset

The network dataset to be built.

Network Dataset Layer
Force Full Build
(Optional)

Specifies whether the full network will be built or only the parts of the network in dirty areas.

  • Checked—The full network will be built.
  • Unchecked—Only the parts of the network that have been changed since the last build will be built. This is the default.
Boolean

Derived Output

LabelExplanationData Type
Updated Input Network Dataset

The updated network dataset.

Network Dataset Layer

arcpy.management.BuildNetwork(in_network_dataset, {force_full_build})
NameExplanationData Type
in_network_dataset

The network dataset to be built.

Network Dataset Layer
force_full_build
(Optional)

Specifies whether the full network will be built or only the parts of the network in dirty areas.

  • FORCE_FULL_BUILDThe full network will be built.
  • NO_FORCE_FULL_BUILDOnly the parts of the network that have been changed since the last build will be built. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_network_dataset

The updated network dataset.

Network Dataset Layer

Code sample

BuildNetwork example 1 (Python window)

Run the tool using all parameters.

network = "C:/Data/Paris.gdb/Transportation/ParisMultimodal_ND"
arcpy.na.BuildNetwork(network)
BuildNetwork example 2 (stand-alone script)

The following Python script demonstrates how to use the BuildNetwork function in a stand-alone script.

# Name: BuildNetwork_ex02.py
# Description: Build a network dataset.
# Requirements: Network Analyst Extension 

#Import system modules
import arcpy
from arcpy import env
import sys
import os
import shutil

try:
    #Check out Network Analyst license if available. Fail if the Network Analyst license is not available.
    if arcpy.CheckExtension("network") == "Available":
        arcpy.CheckOutExtension("network")
    else:
        raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
    
    #Set environment settings
    env.workspace = "C:/data/SanFrancisco.gdb"
    
    #Set local variables
    inNetworkDataset = "Transportation/Streets_ND"
    
    #Build the network dataset
    arcpy.BuildNetwork_na(inNetworkDataset)
    
    #If there are any build errors, they are recorded in a BuildErrors.txt file
    #present in the system temp directory. So copy this file to the directory
    #containing this script
    
    #First get the path to the system temp directory
    tempDir = os.environ.get("TEMP")
    if tempDir:
        shutil.copy2(os.path.join(tempDir,"BuildErrors.txt"),sys.path[0])
    
    print("Script completed successfully.")

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print("An error occurred on line %i" % tb.tb_lineno)
    print(str(e))

Environments