[GIS] How to check if vertex exists (on polyline) based on location of point layer using ArcPy

arcgis-10.1arcgis-desktoparcpyintersectiontopology

Using ArcGIS for Desktop Advanced 10.1 (with all extensions)

I am building a centerline network that will be used by a MapObjects program to do routing based on "turns at any vertex" (as opposed to turns only at endpoints…) What I am trying to do is identify overpasses/underpasses that have a shared vertex with the road that crosses it (but is not considered an intersection) If there is a shared vertex, then the mapping program will (incorrectly) make a turn where there is not one physically possible. What I've done so far is build a topology using the "Must not intersect (Line)" rule. I export the errors to a feature class, and now I have a bunch of points at intersections that I need to check. What I'm wondering is if there is a way to cycle through each point and check to see if a vertex exists where the centerline intersects the point. Here's what I've come up with so far…

import arcpy

fcPoints = "C:/MyPointLayer..."
fcCenterlines = "C:/MyCenterlineLayer..."

rows = arcpy.UpdateCursor(fcPoints)
for row in rows:
    # For each point, select the centerlines that touch (intersect) that point
    arcpy.SelectLayerByAttribute_management(fcPoints, "NEW_SELECTION", "\"OBJECTID\" = " + str(row.getValue("OBJECTID")))
    arcpy.SelectLayerByLocation_management(fcCenterlines, "INTERSECT", fcPoints)
    # Need code here to cycle through each selected centerline and determine if a vertex exists at the point's SHAPE@XY location?
    #PSEUDO CODE:
    for each line in selection:
        vertexExists = False
        for each vertex in line:
            if vertex.xy == point.xy:
                vertexExists = True

        # If there is a matching vertice, then update a field in the point fc to "FLAG" it...
        if vertexExists == True:
            row.setValue("FLAG", "CHECK THIS INTERSECTION")
            cursor.updateRow(row)

Or…. is there an easier way…? I would be looking at about 2000 points to check…

Best Answer

A way of achieving this is to "explode" you polyline into its individual vertices using the feature to vertices tool. You can then run the Generate near table tool with this layer on your intersection points layer. A distance of zero would indicate they are the same location.

Both these tools require you to have an Advance license level.