for loop not iterating for every file in list for CostDistance

Discussion created by gicinc on Aug 9, 2013
Latest reply on Oct 25, 2013 by teresamolin
I've been trying to automate CostDistance and eventually create corridors. I've finally got a code to actually work sort of. I checked my results and realized that only one of the shapefiles (they're single feature shapefiles I created using the Split tool) in the list had actually calculated cost distance and it had only done it to the envelope for the feature. I'm still very new to python, this is my 3rd working(ish) script, and would appreciate any pointers. I am hoping to have this script calculate cost distance across the entire cost raster and reiterate for each node in my list.

#Import arcpy and set environments, relative pathways.
import sys, os
print 'sys.argv[0] =', sys.argv[0] 
pathname = os.path.dirname(sys.argv[0]) 
print 'path =', pathname
print 'full path =', os.path.abspath(pathname) 
import arcpy
from arcpy import env
from import *
pathname = os.path.dirname(sys.argv[0])
env.workspace = pathname + "\GI Network.gdb"
env.overwriteOutput = True

#Variables for script.
cost = "imp_all"
uniquebacklink = arcpy.CreateUniqueName("backlink")
uniqueCostDist = arcpy.CreateUniqueName("NodeCostDist")
outbacklink = "backlink"

#List nodes in workspace for geoprocessing.
listNodes = arcpy.ListFeatureClasses("Node*")
print listNodes

#Execute CostDistance for each Node in NodeBank.
for node in listNodes:
        outCostDistance =, cost, "", uniquebacklink)


Also - PythonWin is now saying that I do not have a license for CostDistance yet I can run the script with no problem in ArcMap once I import it to my toolbox. Any ideas on that?