I have written a script which is supposed to loop through all the rasters in a folder and perform a slope analysis on each raster and save the results in another folder.
I keep getting the following error:
< type 'exceptions.RuntimeError'>: ERROR 000875: Output raster: C:\Slope_Outputs\burd_25m_dem_slope's workspace is an invalid output workspace.
Here's my code:
class LicenseError(Exception): pass # Set desktop license used to ArcView # import arcview import arcpy from arcpy import env try: if arcpy.CheckExtension("Spatial") == "Available": arcpy.CheckOutExtension("Spatial") else: # Raise a custom exception raise LicenseError except LicenseError: arcpy.AddMessage("Spatial Analyst license is unavailable") except: print arcpy.GetMessages(2) from arcpy.sa import * originLocation = arcpy.GetParameterAsText(0) slopeMeasurement = arcpy.GetParameterAsText(1) destinationLocation = arcpy.GetParameterAsText(2) arcpy.env.workspace = originLocation rasterList = arcpy.ListRasters("*") for raster in rasterList: finalDestination = destinationLocation+"\\"+raster+"_slope" arcpy.AddMessage(finalDestination) outSlope=arcpy.sa.Slope(raster, slopeMeasurement) arcpy.AddMessage(outSlope) outSlope.save(finalDestination)
I'm not really sure why I'm getting this error. Any ideas?