0

I am trying to set an "output path" in my Arcpy script in order to not have to repeat the path everitime I want to save a dataset after applying a tool.

So I set the output path like:

output_path = "C:/PhD/output"

But Python is sending this error message:

RuntimeError: ERROR 010240: could not save raster dataset to C:\PhD\output with output format GRID

I`ve had a look at the tips given by Slslam in his question bellow

RuntimeError: ERROR 010240 in Con operation in arcpy

So I have separated scratch and output workspaces and I have imported multiprocessing, but it is still not working, as ERROR 010240 keep being sent.

I am using ArcMap 10.2.

Can anyone shed light on this problem, please?

# Import system modules
import arcpy, multiprocessing
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Set environment settings
env.workspace = "C:/PhD/raster"
output_path = "C:/PhD/output"

# Set local variables
inRaster1 = Raster("slope_angle")

# Execute raster calculator to create a slope percentage raster showing values <= 9% and the remaining
#values set to zero

outRas1 = Con(inRaster2 <= 9, 1, 0)
outRas1.save(output_path)

Phil
  • 58
  • 8
  • Have you tried a different output type? outRas1.save("C:/PhD/output.tif") – BERA Apr 16 '20 at 05:34
  • Yes, and it works. But in reality the path is much much longer than "C:/PhD/output,tif", and in addition, the real script have many raster outputs. So I want to make my script more elegant, instead of having to write the entire output path every time I need to save a new raster dataset. Thanks! – Phil Apr 17 '20 at 00:28

0 Answers0