Create Network Dataset From Template (Network Analyst Tools)
Summary
Creates a new network dataset with the schema contained in the input template file (.xml). All the feature classes and input tables required for creating the network dataset must already exist before this tool is executed.
Usage
This tool creates a new network dataset using the schema from the template file. Use the Create Template From Network Dataset tool to create the schema for the new network dataset. The name of the output network dataset is specified in the input template file.
The newly created network dataset will need to be built using the Build Network tool.
The template file (.xml) created by the Create Template From Network Dataset tool containing the schema of the output network dataset to be created.
File
Output Feature Dataset
The feature dataset containing the feature classes that will take part in the network dataset being created. The network will be created in this dataset using the name specified in the network dataset template.
Feature Dataset
Derived output
Label
Explanation
Data type
Output Network
A new network dataset with the schema contained in the template file.
The template file (.xml) created by the Create Template From Network Dataset tool containing the schema of the output network dataset to be created.
File
output_feature_dataset
The feature dataset containing the feature classes that will take part in the network dataset being created. The network will be created in this dataset using the name specified in the network dataset template.
Feature Dataset
Derived output
Name
Explanation
Data type
output_network
A new network dataset with the schema contained in the template file.
Network Dataset
Code sample
CreateNetworkDatasetFromTemplate example 1 (Python window)
CreateNetworkDatasetFromTemplate example 2 (stand-alone script)
The following stand-alone Python script demonstrates how the CreateNetworkDatasetFromTemplate tool can be used to create a new network dataset from an existing template.
# Name: NetworkDatasetTemplate_workflow.py
# Description: Create a new network dataset with the same schema as an existing
# network dataset
# Requirements: Network Analyst extension
#Import system modules
import arcpy
import os
try:
#Set local variables
original_network = "C:/data/Region1.gdb/Transportation/Streets_ND"
new_network_location = "C:/data/Region2.gdb/Transportation"
xml_template = "C:/data/NDTemplate.xml"
#Create an XML template from the original network dataset
arcpy.na.CreateTemplateFromNetworkDataset(original_network, xml_template)
#Create the new network dataset in the output location using the template.
#The output location must already contain feature classes and tables with
#the same names and schema as the original network.
arcpy.na.CreateNetworkDatasetFromTemplate(xml_template,
new_network_location)
#Build the new network dataset
arcpy.na.BuildNetwork(os.path.join(new_network_location, "Streets_ND"))
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)))