需要 Network Analyst 许可。
描述
升级网络数据集的方案。 升级网络数据集可以允许网络数据集利用当前软件版本中可用的新功能。
使用方法
升级网络数据集之前,必须使用升级地理数据库工具将地理数据库升级到最新版本。
语法
arcpy.na.UpgradeNetwork(in_network_dataset)
参数 | 说明 | 数据类型 |
in_network_dataset | 要升级的网络数据集。 网络数据集必须是基于地理数据库的网络数据集。 | Network Dataset Layer |
派生输出
名称 | 说明 | 数据类型 |
out_network_dataset | Network Dataset Layer |
代码示例
UpgradeNetwork 示例 1(Python 窗口)
使用所有参数执行工具。
import arcpy
arcpy.env.workspace = "C:/Data/Socal.gdb"
arcpy.UpgradeNetwork_na("Transportation/Streets_ND")
UpgradeNetwork 示例 2(独立脚本)。
以下独立 Python 脚本演示了如何使用 UpgradeNetwork 工具来升级网络数据集方案。
# Name: UpgradeNetwork_Workflow.py
# Description: Upgrades the schema of a network dataset by first upgrading the
# geodatabase containing the network dataset and then upgrading the
# network dataset. The network dataset is also built so that it can
# be used to perform network analyses.
# Requirements: Network Analyst Extension
#Import system modules
import arcpy
from arcpy import env
try:
#Check out the Network Analyst extension license
arcpy.CheckOutExtension("Network")
#Set environment settings
env.workspace = "C:/data/RhodeIsland.gdb"
env.overwriteOutput = True
#Set local variables
#inNetworkDataset = "Transportation/Streets_ND"
inNetworkDataset = "RhodeIsland/RhodeIsland_ND"
#Before upgrading the network dataset, upgrade the file GDB that contains
#the network dataset
arcpy.UpgradeGDB_management(env.workspace)
#Upgrade the network dataset
arcpy.UpgradeNetwork_na(inNetworkDataset)
#The upgraded network dataset is not built. So build the network dataset
arcpy.BuildNetwork_na(inNetworkDataset)
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 occured on line %i" % tb.tb_lineno
print str(e)
环境
许可信息
- Basic: 需要 Network Analyst
- Standard: 需要 Network Analyst
- Advanced: 需要 Network Analyst