AnsweredAssumed Answered

Automate creation of Cost Distance Raster with Python

Question asked by thomas.wirth@wwf.ch on May 20, 2016
Latest reply on May 20, 2016 by GSCUser85

Hi everybody

I need some help on the automation processin which I try to create several cost distance raster. In a polygon feature class I have several records and I should create for each record an individual cost distance raster. So far script looks like this:

 

rCost = "U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Test.gdb\F_Offen_Final"
fcStart = r"U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Test.gdb\Startorte"
cursor = arcpy.SearchCursor(fcStart)
count = 1
for row in cursor:
    strcount = str(count)
    CD = CostDistance(fcStart,rCost, "100000")
    CD.save("U:\Daten\WWFgis\CH\Projekte\Raumplanung\Landschaften\Cost_Distance.gdb\C"+strcount)
    count +=1

 

It perfectly runs as many times I have records in the feature class, but the result is always the same for every cost distance raster as all records of the feature were selected for the creation of the cost distance raster instead of only one and the next one in the next loop.

 

Any suggestions?

 

Thomas

 

Outcomes