计算位置 (网络分析)

摘要

向包含要素网络位置的输入要素添加字段。该工具用于将网络位置信息存储为要素属性以便快速地将要素加载为网络分析图层的输入。

用法

语法

CalculateLocations_na (in_point_features, in_network_dataset, search_tolerance, search_criteria, {match_type}, {source_ID_field}, {source_OID_field}, {position_field}, {side_field}, {snap_x_field}, {snap_y_field}, {distance_field}, {snap_Z_field}, {location_field}, {exclude_restricted_elements}, {search_query})
参数说明数据类型
in_point_features

要计算网络位置的输入要素。

对于线和面要素,由于网络位置信息存储在 blob 字段中(在位置范围字段参数中指定),所以仅支持地理数据库要素类。

Table View
in_network_dataset

The network dataset used to calculate the locations.

如果将网络分析图层的子图层用作输入要素,则该参数必须设置为网络分析图层所引用的网络数据集。

Network Dataset Layer
search_tolerance

在网络上定位输入要素所需的搜索容差。搜索容差以外的要素将保持未定位状态。该参数包括容差的值和单位。

计算线或面要素的位置时,不使用该参数。在这种情况下,使用“#”作为参数值。

Linear unit
search_criteria
[[Source, SnapType],...]

指定查找位置时将搜索网络数据集中的哪些源以及将使用几何的什么部分(也称为捕捉类型)。

该参数值被指定为具有嵌套列表的列表。嵌套列表由两个值组成,分别表示每个网络源的名称和捕捉类型。捕捉类型通过关键字“SHAPE”、“MIDDLE”、“END”或“NONE”来指定。例如,查找位置时,参数值 [["Streets","SHAPE"],["Streets_ND_Junctions","NONE"]] 指定搜索可定位于 Streets 源的形状,而不可定位于 Streets_ND_Junctions 源。

要为单一网络源指定多个捕捉类型,请使用捕捉类型关键字的组合形式,用下划线将关键字分开。例如,MIDDLE_END 指定位置可以捕捉到网络源的中部或末尾。

For geodatabase network datasets, the snap types can be specified for each subtype of the network source.

When calculating locations for line or polygon features, only the Shape snap type is used even if other snap types are specified.

Value Table
match_type
(可选)
  • MATCH_TO_CLOSEST将新网络位置与所有已在搜索条件中指定捕捉类型的源中的最近的网络源匹配。这是默认设置。
  • PRIORITY将新网络位置与第一个在搜索条件中指定捕捉类型的网络源匹配。这些源按照优先级顺序进行搜索;当在搜索容差内找到位置时,搜索停止。

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Boolean
source_ID_field
(可选)

Name of the field to be created or updated with the source ID of the computed network location. A field called "SourceID" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
source_OID_field
(可选)

Name of the field to be created or updated with the source OID of the computed network location. A field called "SourceOID" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
position_field
(可选)

Name of the field to be created or updated with the percent along of the computed network location. A field called "PosAlong" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
side_field
(可选)

Name of the field to be created or updated with the side of edge on which the point feature is located on the computed network location. A field called "SideOfEdge" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
snap_x_field
(可选)

Name of the field to be created or updated with the x-coordinate of the computed network location. A field called "SnapX" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
snap_y_field
(可选)

Name of the field to be created or updated with the y-coordinate of the computed network location. A field called "SnapY" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
distance_field
(可选)

Name of the field to be created or updated with the distance of the point feature from the computed network location. A field called "Distance" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

Field
snap_Z_field
(可选)

Name of the field to be created or updated with the z-coordinate of the computed network location. A field called "SnapZ" is created or updated by default.

The parameter is not used when calculating locations for line or polygon features. In such cases, use "#" as the parameter value.

计算点要素的位置时,仅当输入网络数据集支持基于网络源的 z 坐标值的连通性时,才会使用该参数。在所有其他情况下,使用“#”作为参数值。

Field
location_field
(可选)

Name of the field to be created or updated with the location ranges of the computed network locations for the line or polygon features. A field called "Locations" is created or updated by default.

仅当计算线或面要素的位置时,才使用此参数。对于输入点要素,使用“#”作为参数值。

Field
exclude_restricted_elements
(可选)

此参数仅适用于输入要素来自网络分析图层的子图层并且不是障碍对象的情况。在所有其他情况下,使用“#”作为参数值。

  • EXCLUDE指定将网络位置仅放置在网络的可遍历部分。这样可防止将网络位置放在因限制或障碍而无法到达的元素上。使用该选项重新定位网络位置之前,请确保已向网络分析图层添加了所有限制型障碍,以便得到预期结果。
  • INCLUDE指定将网络位置放置在网络的所有元素上。如果使用该选项重新定位的网络位置被放置在受限元素上,那么在求解过程中,可能无法到达这些网络位置。
Boolean
search_query
[[Source, Expression],...]
(可选)

Specifies a query to restrict the search to a subset of the features within a source feature class. This is useful if you don't want to find features that may be unsuited for a network location. For example, if you are loading centroids of polygons and don't want to locate on local roads, you can define a query that searches for major roads only.

该参数值被指定为具有嵌套列表的列表。嵌套列表由两个值组成,分别表示所有网络源的名称和 SQL 表达式。对于不同的网络源要素类类型,SQL 表达式的语法略有不同。例如,如果要查询存储在文件或 ArcSDE 地理数据库中的源要素类、shapefile 或 SDC,需将字段名用双引号括起:"CFCC"。如果要查询存储在个人地理数据库中的源要素类,需将字段用方括号括起:[CFCC]

如果您不想指定特定源的查询,请使用 "#" 作为 SQL 表达式的值,或者将源名称和 SQL 表达式从参数值中排除。如果您不想指定所有网络源的查询,请使用 "#" 作为参数值。

例如,参数值 [["Streets","\"CFCC\" = 'A15'"], ["Streets_ND_Junctions",""]] 指定了 Streets 源要素类的 SQL 表达式,而没有指定 Streets_ND_Junctions 源要素类的表达式。注意:用于括字段名 CFCC 的双引号通过反斜杠字符进行转义,以避免 Python 解释程序出现分析错误。

Value Table

代码示例

CalculateLocations 示例 1(Python 窗口)

仅使用所需参数计算点要素的位置。

import arcpy
arcpy.env.workspace = "C:/ArcTutor/Network Analyst/Tutorial/SanFrancisco.gdb"
arcpy.CalculateLocations_na("Analysis/Stores","Transportation/Streets_ND",
                            "5000 Meters",[["Streets","SHAPE"],
                                           ["Streets_ND_Junctions","NONE"]])
CalculateLocations 示例 2(Python 窗口)

根据网络源的子类型计算点要素的位置。

import arcpy
arcpy.env.workspace = "C:/ArcTutor/Network Analyst/Tutorial/Paris.gdb"
arcpy.CalculateLocations_na(
    "Analysis/Warehouses","Transportation/ParisNet","5000 Meters",
    [["Streets : Highways","NONE"],["Streets : Major Roads","NONE"],
     ["Streets : Local Streets","SHAPE"],["ParisNet_Junctions", "NONE"]],
    "MATCH_TO_CLOSEST","SID","SOID","PA","SOE","SnapX","SnapY","Distance",
    "","","","")
CalculateLocations 示例 1(Python 窗口)

计算面要素的位置。

import arcpy
arcpy.env.workspace = "C:/ArcTutor/Network Analyst/Tutorial/SanFrancisco.gdb"
arcpy.CalculateLocations_na("Basemap/Parks","Transportation/Streets_ND","",
                            [["Streets","SHAPE"],
                             ["Streets_ND_Junctions","NONE"]],
                            location_field="Locations")
CalculateLocations 示例 4(独立 Python 脚本)

以下 Python 脚本演示了如何在独立脚本中使用 CalculateLocations 工具。

# Name: CalculateLocations_ex04.py
# Description: Calculate network locations for fire stations. Make sure that the 
#              fire stations are not located on the freeways.
# Requirements: Network Analyst Extension 

#Import system modules
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
inFeatures = "Analysis/FireStations"
inNetworkDataset = "Transportation/Streets_ND"
searchTolerance = "2000 Meters"
searchCriteria = [["Streets","SHAPE"],["Streets_ND_Junctions","NONE"]]
searchQuery = [["Streets",'"FREEWAY" = 0'],["Streets_ND_Junctions",""]]

#Calculate network locations and store them in defaut field names
arcpy.CalculateLocations_na(inFeatures,inNetworkDataset,searchTolerance,
                            searchCriteria,"MATCH_TO_CLOSEST", 
                            exclude_restricted_elements="EXCLUDE",
                            search_query=searchQuery)
print "Script completed successfully."

环境

相关主题


7/10/2012