ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

通过模板创建网络数据集

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

使用输入模板文件 (.xml) 中包含的方案创建新的网络数据集。在执行该工具之前,必须确保创建网络数据集所需的所有要素类和输入表已经存在。

使用方法

  • 该工具会使用模板文件中的方案创建新的网络数据集。使用从网络数据集创建模板工具为新的网络数据集创建方案。输入模板文件中对输出网络数据集的名称进行了指定。

  • 新创建的网络数据集将需要使用构建网络工具进行构建。

语法

arcpy.na.CreateNetworkDatasetFromTemplate(network_dataset_template, output_feature_dataset)
参数说明数据类型
network_dataset_template

使用从网络数据集创建模板工具创建的模板文件 (.xml) 中包含要创建的输出网络数据集方案。

File
output_feature_dataset

要素数据集中包含将加入所创建的网络数据集的要素类。将根据网络数据集模板中指定的名称在此数据集中创建网络。

Feature Dataset

派生输出

名称说明数据类型
output_network

使用输入模板文件中包含的方案的新网络数据集。

网络数据集

代码示例

CreateNetworkDatasetFromTemplate 示例 1(Python 窗口)

使用所有参数执行此工具。

new_network_location = "C:/data/NewNetwork.gdb/Transportation"
xml_template = "C:/data/NDTemplate.xml"
arcpy.na.CreateNetworkDatasetFromTemplate(new_network_location, xml_template)
CreateNetworkDatasetFromTemplate 示例 2(独立脚本)

以下独立 Python 脚本演示了如何使用 CreateNetworkDatasetFromTemplate 工具通过现有模板创建新的网络数据集。

# 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)))

环境

  • 当前工作空间

许可信息

  • Basic: 需要 Network Analyst
  • Standard: 需要 Network Analyst
  • Advanced: 需要 Network Analyst

相关主题

  • 网络数据集工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明