pragersd

Speeding up Spatial Select?

Discussion created by pragersd on Apr 3, 2012
Latest reply on Apr 3, 2012 by pragersd
Hi Everyone,

I am working with a large dataset that I need to cursor through and retain the results of some spatial selects to generate another dataset for use outside of the GIS. The input are the junctions and edges of a road network. The process flow, idea anyway, is to grab an edge, perform a spatial select, figure out what junctions are connected, store this information and move on.

This works very well, but is VERY slow. I have a spatial overlay approach to generate the same data but this is not satisfactory when the data are connected based on vertical elevation values. The code looks something like this:

arcpy.MakeFeatureLayer_management(edgeSource, 'edge_lyr')
arcpy.MakeFeatureLayer_management(junctionSource, 'junc_lyr')

ff = T.time()
edgeList = {}
nodePos = {}
goNogo = {}
edges = arcpy.SearchCursor(edgeSource, "", "")
for edge in edges:
    newID = edge.getValue(edgeIDItem)
    cost = edge.getValue(edgeCostItem)
    expr =  edgeIDItem + " = %s " % newID
    arcpy.SelectLayerByAttribute_management ("edge_lyr", "NEW_SELECTION", expr)
    arcpy.SelectLayerByLocation_management('junc_lyr', 'intersect', 'edge_lyr')

    newEdge = []
    juncs = arcpy.SearchCursor('junc_lyr')
    for junc in juncs:
        jid = junc.getValue(juncIDItem)
        geom = junc.Shape.getPart()
        newEdge.append(jid)
        nodePos[jid] = (geom.X, geom.Y)
        goNogo[jid] = [junc.getValue(nogoIDItem), junc.getValue(nogoDistItem)]
    newEdge.append(cost)
    if len(newEdge) == 3:
        edgeList[newID] = newEdge



Does anyone have any ideas how a process like this might be sped up?

Thanks!

Steve

Outcomes