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.
Syntax
CreateNetworkDatasetFromTemplate(network_dataset_template, output_feature_dataset)
Parameter | Explanation | Data Type |
network_dataset_template | 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
Execute the tool using all parameters.
new_network_location = "C:/data/NewNetwork.gdb/Transportation"
xml_template = "C:/data/NDTemplate.xml"
arcpy.na.CreateNetworkDatasetFromTemplate(new_network_location, xml_template)
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:
#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 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)))
Environments
Licensing information
- Basic: Requires Network Analyst
- Standard: Requires Network Analyst
- Advanced: Requires Network Analyst