2

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...

  • Uh, yeah, that's a pretty good idea... wasn't aware of that tool... that works perfectly... thanks! – Jason Miller Dec 3 '13 at 2:29
  • @Hornbydd I think you should turn your Comment into an Answer because it looks like it answered the Question. – PolyGeo Apr 6 '14 at 8:14
1

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.

0

Hornbydd has a valid answer of course if you have the advanced license. Here is the work around if you do not:

  • Use the Make Feature Layer method on your polyline layer before your selection methods, to store the selected features.
  • Finally, to pull out the selected polyline vertices (from the feature layer) and get their x/y coordinates to compare against your point layer (coordinate field values) you can reference this script snippet from this forum post:
updateRows = arcpy.UpdateCursor(lineFC) # for your situation a search cursor will do
for updateRow in updateRows: # looping through lines
   vertexList = []
   shapeObj = updateRow.getValue(shapeFieldName)
   partObj = shapeObj.getPart(0)
   for pointObj in partObj: 
      vertexList.append((pointObj.X, pointObj.Y))
      # continue with your update cursor on your point layer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.