Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am attemping to call arcpy.sa.CostDistance to calculate the cost distance to a source point as well as generate the optional Cost Back link raster:

arcpy.sa.CostDistance("input", cost, "costDist", "", "costBackLink")

Which yields this error when executed within the Python Windows of ArcGIS:

>>> arcpy.sa.CostDistance("input", cost, "costDist", "", "costBackLink")
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: CostDistance() takes at most 4 arguments (5 given)

Oddly though, the exact same processing when executed via the Toolbox executes fine. The inline help that appears next to the Python Window when entering a function name also references the 5 arguments.

Why is this happening?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Take a look at the input guidelines here. There are four inputs. Also, the third input is a distance value and should thus be either a hard coded number or a variable representing a number. Your return should be assigned to the operation itself:

returnRaster = arcpy.sa.CostDistance("input", cost, numericValue, "costBackLink")
share|improve this answer
    
Absolutely correct, I need to read more carefully! –  mindless.panda Dec 21 '12 at 0:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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