Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attemping to call to calculate the cost distance to a source point as well as generate the optional Cost Back link raster:"input", cost, "costDist", "", "costBackLink")

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

>>>"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
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 ="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


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.