Skip to main content
1 of 10

While looping with arcpy: ERROR 010240: Could not save raster dataset

Here is the code that is causing this error:

import arcpy
import numpy as np
import math
from arcpy.sa import *

# Get the input arguements

# Input DEM
input_raster = arcpy.GetParameterAsText(0)

# Output 
output_raster = arcpy.GetParameterAsText(1)

# Input Discharge
mean_discharge = arcpy.GetParameterAsText(2)

# Input number of timesteps
input_timestep = arcpy.GetParameterAsText(3)

arcpy.env.overwriteOutput = True
arcpy.env.scratchWorkspace = r"C:\SedMod\SedMod\Workspace.gdb"

actual_timestep = 0

while actual_timestep < input_timestep:
    # Slope calculation

    # Set local variables
    out_measurement = "PERCENT_RISE"

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

    #Execute Slope
    out_slope = Slope(input_raster, out_measurement, )

    # Convert to gradient
    slope_raster = out_slope / 100

There is a lot of code in here but not responsible for the error?

and this is how the while loop ends:

    actual_timestep = actual_timestep + 1

    new_elevation.save(output_raster)   

The error I am getting is:

Traceback (most recent call last): File "C:\SedMod\SedMod\Slope1.py", line 47, in out_slope = Slope(input_raster, out_measurement, ) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 5523, in Slope z_factor) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper result = wrapper(*args, **kwargs) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 5518, in wrapper z_factor) File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing_base.py", line 498, in return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: ERROR 010240: Could not save raster dataset to C:\SedMod\SedMod\Workspace.gdb\numpy_ras6 with output format FGDBR.

Failed to execute (SedModv1).