计算位置 (网络分析)
摘要
向包含要素网络位置的输入要素添加字段。该工具用于将网络位置信息存储为要素属性以便快速地将要素加载为网络分析图层的输入。
用法
-
该工具用于计算可输入到添加位置工具的位置字段。应该对要多次输入到网络分析图层的要素应用该工具。一旦计算完位置,便可使用添加位置工具中的使用网络位置字段代替几何参数快速将要素作为网络位置进行加载。
-
还可在使用一组其他搜索选项的情况下,通过该工具来对网络分析图层中未定位的网络位置重新进行计算。例如,如果路径网络分析图层中的停靠点最初是按 500 米的搜索容差进行添加的,而少数停靠点未进行定位,那么您可以使用按属性选择图层工具等来选择未定位的停靠点,然后在将停靠点子图层指定为输入要素并且选择一个较大搜索容差的情况下重新运行该工具。
-
如果用作网络数据集中的网络源的要素类具有有效且最新的空间索引,那么该工具的运行速度将显著提高。
语法
参数 | 说明 | 数据类型 |
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 (可选) |
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 (可选) |
此参数仅适用于输入要素来自网络分析图层的子图层并且不是障碍对象的情况。在所有其他情况下,使用“#”作为参数值。
| 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 |
代码示例
仅使用所需参数计算点要素的位置。
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"]])
根据网络源的子类型计算点要素的位置。
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", "","","","")
计算面要素的位置。
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")
以下 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."