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.
Usage
The tool will warn if any build errors are encountered when building the network. As these errors indicate potential problems that may prevent the network from working as intended, they should be examined and addressed.
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.
An SDC network dataset cannot be built, as it is read-only.
Syntax
arcpy.na.BuildNetwork(in_network_dataset)
Parameter | Explanation | Data Type |
in_network_dataset | The network dataset to be built. | Network Dataset Layer |
Derived Output
Name | Explanation | Data Type |
out_network_dataset | The updated network dataset. | Network Dataset Layer |
Code sample
BuildNetwork example 1 (Python window)
Execute the tool using all parameters.
network = "C:/Data/Paris.gdb"
arcpy.na.BuildNetwork(network)
BuildNetwork example 2 (stand-alone script)
The following Python script demonstrates how to use the BuildNetwork tool in a stand-alone script.
# Name: BuildNetwork_ex02.py
# Description: Build a network dataset.
# Requirements: Network Analyst Extension
#Import system modules
import sys
import os
import shutil
import arcpy
from arcpy import env
#Check out the Network Analyst extension license
arcpy.CheckOutExtension("Network")
#Set environment settings
env.workspace = "C:/Data/SanFrancisco.gdb"
#Set local variables
network = "Transportation/Streets_ND"
#Build the network dataset
arcpy.na.BuildNetwork(network)
#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.
temp_dir = os.environ.get("TEMP")
if temp_dir:
shutil.copy2(os.path.join(temp_dir, "BuildErrors.txt"), sys.path[0])
print("Script completed successfully.")
Environments
Licensing information
- Basic: Requires Network Analyst
- Standard: Requires Network Analyst
- Advanced: Requires Network Analyst