Answers:
对于一次单个功能,您可以使用普通的“ 按位置选择”对话框轻松交互地进行此操作,并使用以下键作为线对线叠加的空间关系类型的指南(来自“ 按位置选择:图形示例”):
(来源:arcgis.com)使用线选择线
交点A,C,D,E,F,G,H,I,J 包含G,H COMPLETELY_CONTAINS G CONTAINS_CLEMENTINI G,H 在F,H之内 COMPLETELY_WITHIN F WITHIN_CLEMENTINI F,H ARE_IDENTICAL_TO H BOUNDARY_TOUCHES C,E
在这种情况下,相关的关系类型为INTERSECT
和BOUNDARY_TOUCHES
。从上图可以看到,您可以用于BOUNDARY_TOUCHES
选择接触线端点的要素。如果恰好选择了两个功能,则您的情况为1。如果某个功能没有被任何其他功能触及,只是被它们相交,BOUNDARY_TOUCHES
则将什么也不会选择。INTERSECT
将选择所有相交的要素,无论它们是否接触端点。因此,如果您知道没有任何特征与端点相关,但是发现有特征相交,则说明案例2。
要使过程自动化,您可以使用以下Python脚本(如果需要,可以实现为脚本工具)来计算要素类或图层中每个要素的接触和相交的数量:
import arcpy
################################ Configuration #################################
numTouchesField = "NUM_TOUCHES"
numIntersectionsField = "NUM_INTERSECTIONS"
################################################################################
def countTouches(layer, feature):
"""Returns the number of times the boundary of a feature touches other
features in the same feature layer."""
return countSpatialRelation(layer, feature, "BOUNDARY_TOUCHES")
def countIntersections(layer, feature):
"""Returns the number of times a feature intersects other features in the
same feature layer."""
return countSpatialRelation(layer, feature, "INTERSECT") - 1 # Subtract 1 because the feature will always intersect its clone in the feature layer
def countSpatialRelation(layer, feature, relation):
"""Returns the number of times a feature meets the specified spatial
relationship with other features in the same feature layer."""
arcpy.SelectLayerByLocation_management(layer, relation, feature)
count = int(arcpy.GetCount_management(layer).getOutput(0))
return count
def addField(table, fieldName, fieldType):
"""Adds a fields of the given name and type to a table, unless a field with
the same name already exists."""
desc = arcpy.Describe(table)
fieldInfo = desc.fieldInfo
fieldIndex = fieldInfo.findFieldByName(fieldName)
if fieldIndex == -1:
# Field does not exist, add it
arcpy.AddField_management(table, fieldName, fieldType)
def countTouchesAndIntersections(layer):
"""Adds and populates fields describing the number of times each feature
touches and intersects other features in the feature layer."""
addField(layer, numTouchesField, "LONG")
addField(layer, numIntersectionsField, "LONG")
desc = arcpy.Describe(layer)
shapeField = desc.shapeFieldName
rows = arcpy.UpdateCursor(layer)
for row in rows:
feature = row.getValue(shapeField)
row.setValue(numTouchesField, countTouches(layer, feature))
row.setValue(numIntersectionsField, countIntersections(layer, feature))
rows.updateRow(row)
del row, rows
if __name__ == "__main__":
layer = arcpy.MakeFeatureLayer_management(arcpy.GetParameterAsText(0))
countTouchesAndIntersections(layer)
一旦运行,您就可以轻松查询两次精确接触且两次相交的要素(案例1),以及一次触摸0次并且恰好相交两次的要素(案例2)。
定义查询示例:
"NUM_TOUCHES" = 2 AND "NUM_INTERSECTIONS" = 2
"NUM_TOUCHES" = 0 AND "NUM_INTERSECTIONS" = 2
请参见下面的屏幕快照,以了解找到的两种情况的实例:
请注意,使用现实世界的数据时,通常情况下,路段会在交叉路口处分解,并且只有当道路相互交叉时,如在立交桥或桥梁处,才会出现悬挂。因此,通常您具有与触摸相交的相同数量的要素。
对于更一般的情况,您可能希望通过检查是否悬垂来查找"NUM_INTERSECTIONS" > "NUM_TOUCHES"
。
顶点分割线(数据管理)
“创建一个要素类,其中包含通过在其顶点处分割输入线或面边界而生成的线”
保持归因。
http://help.arcgis.com/zh-CN/arcgisdesktop/10.0/help/index.html#//00170000003z000000
您还可以提取网络的节点。在情况1中,您将获得2个节点,每个节点的化合价为4。在情况2中,没有节点。