摘要
返回一个布尔值,用来指示指定的网络数据集内与指定的要素图层中的要素相交的边源要素的数量是否小于或等于指定中断值。对于可作为线障碍或面障碍加载到网络分析图层中的要素,该函数有助于限制其数量。
讨论
该函数用于限制可加载到网络分析图层子图层中的要素(尤其是线障碍和面障碍)数量。加载面障碍时,软件需要算出面要素与网络数据集中的边源的交点。如果面要素与很多边源(例如州或县边界)相交,此过程可能很慢。例如,当创建一个执行路径分析的地理处理服务时,您可能希望限制加载为面障碍的要素数。为了实现合理的服务响应时间,如果面障碍与超过 5,000 个来自网络数据集的边源要素相交,可以限制面障碍的加载。使用该函数可以轻松地执行此类检查。
语法
CheckIntersectingFeatures (network_dataset_path, feature_layer, {cutoff})
参数 | 说明 | 数据类型 |
network_dataset_path | A variable that references the catalog path of the network dataset. Each edge source in this network dataset will be considered while performing the check. The catalog path of a network dataset can be obtained from the dataSource property of a network dataset layer or a network analysis layer object. It can also be obtained from the catalogPath property of a network dataset Describe object. | String |
feature_layer | A variable that references the Layer object containing the features that are intersected with the edge sources. Any selection set or definition query present on the Layer object is honored and can be used to specify only a subset of features. | Layer |
cutoff | An integer value used as a cutoff while performing the check. (默认值为 5000) | Long |
返回值
数据类型 | 说明 |
Boolean | 如果指定与网络数据集中的边源要素相交的要素数小于或等于中断值,该函数返回 True;否则返回 False。 |
代码实例
CheckIntersectingFeatures 示例(工作流)
该示例显示了在考虑将天气条件作为减速障碍的情况下,如何找到一些商店位置之间的最佳路径。它说明了如何使用 CheckIntersectingFeatures 函数检测要用做面障碍的天气面是否与超过指定数量的来自网络数据集的边源要素相交。如果条件不符,脚本将生成标准错误消息。
import arcpy
#Set up the environment
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("network")
#Set up variables
networkDataset = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
polygonBarriers = "C:/Data/WeatberSlowDownAreas.shp"
stops = "C:/Data/SanFrancisco.gdb/Analysis/Stores"
cutoff = 3000
impedanceAttribute = "TravelTime"
outputLayer = "C:/Data/WeatherRoute.lyr"
#Make a feature layer from the catalog path to the shapefile
barriersLayer = arcpy.management.MakeFeatureLayer(polygonBarriers,
"PolygonBarriersLayer").getOutput(0)
#Check if edge features intersected by barrier features are less than 3000
if arcpy.na.CheckIntersectingFeatures(networkDataset, barriersLayer, cutoff):
#Proceed with creating a new route layer and loading the barriers
routeLayer = arcpy.na.MakeRouteLayer(networkDataset, "WeatherRoute",
impedanceAttribute).getOutput(0)
#Get na class names based on the layer
naClasses = arcpy.na.GetNAClassNames(routeLayer, "INPUT")
#Create field mappings for loading barriers as scaled cost polygon barriers
#with a slow down of 40%
fieldMappings = arcpy.na.NAClassFieldMappings(routeLayer,
naClasses["PolygonBarriers"])
fieldMappings["BarrierType"].defaultValue = 1
fieldMappings["Attr_" + impedanceAttribute].defaultValue = 1.4
#Load weather polygons as slow down barriers
arcpy.na.AddLocations(routeLayer, naClasses["PolygonBarriers"],
polygonBarriers, fieldMappings)
#Load stops
arcpy.na.AddLocations(routeLayer, naClasses["Stops"], stops)
#Solve the route
arcpy.na.Solve(routeLayer)
#Save the solved layer as a layer file
arcpy.management.SaveToLayerFile(routeLayer, outputLayer)
else:
#Return a standard error message if the test fails.
arcpy.AddIDMessage("ERROR", 30095, "Polygon Barriers", cutoff)
arcpy.AddMessage("Completed")