AnsweredAssumed Answered

python loop - saving output

Question asked by MathiasKusk.atkins on Dec 17, 2017
Latest reply on Dec 17, 2017 by Dan_Patterson

The script is intended to subtract the loop variable from a raster and save the raster using an appropriate name.

I tried quite a few work-arounds, but all methods seem the hit a wall. The attached image shows that the same simple tool in modelbuilde casts the same error.

Anyone that made something similar?

 

Via this simple python loop:

import arcpy
stepper = 5
for stepper in range (20):

      name="AFVdtm"+str(stepper)
      name= arcpy.sa.Minus("DTM_frostkærLocal.tif",stepper)
      stepper += stepper
      rod = "c:/testmappe/"
      name=name
      eft=".tif"
      sti=rod+name+eft
      name.save(sti)

Traceback (most recent call last):

File "<string>", line 10, in <module>

File "c:\program files\arcgis 2.0\pro\Resources\arcpy\arcpy\sa\Functions.py", line 4331, in Plus

in_raster_or_constant2)

File "c:\program files\arcgis 2.0\pro\Resources\arcpy\arcpy\sa\Utils.py", line 53, in swapper

result = wrapper(*args, **kwargs)

File "c:\program files\arcgis 2.0\pro\Resources\arcpy\arcpy\sa\Functions.py", line 4328, in Wrapper

["Plus", in_raster_or_constant1, in_raster_or_constant2])

RuntimeError: ERROR 000732: Input Raster: Dataset c:/testmappe/ does not exist or is not supported

 

I have tried using relative and absolute paths, which doesn't change anything in the error.

 

 Running it like:

 

import arcpy

stepper = 5

for stepper in range (20):

     name="AFVdtm"+str(stepper)

    name= arcpy.sa.Minus("DTM_frostkærLocal.tif",stepper)

    stepper += stepper

    name.save("c:/testmappe/%name%.tif")

 

Produces the intended output, but continously overwrites it

Attachments

Outcomes