I am trying to create a python script to run several ArcMap tools in succession on a DEM. The script will ideally create a random raster (based on a normal distribution, with a mean of 0 and a standard dev. of 2), then add this to a DEM to form a DEM + random raster. The viewshed tool will then be carried out on this DEM+. I want this to loop 20 times.
This is the code I currently have:
# Program to calculate probable viewshed from a DEM using ArcMap tools # Author: David Ely, 02/06/2016 # Status: Work In Progress # This program must be placed in the same directory folder as the DEM # Import the required libraries import arcpy from arcpy.sa import * arcpy.CheckOutExtension = 'Spatial' # Set the environment to allow overwrites to data arcpy.env.overwriteOutput = True # Load in the DEM and store it's extent print 'DEM file name: ' DEM = Raster(raw_input()) # User inputs the name of the DEM file DEMextent = DEM.extent # Enter the RMSE of the DEM and the output path for the analyses print 'Enter RMSE of DEM: ' RMSE = raw_input() print 'Enter output path for analyses: ' outpath = raw_input() # define i for incremental loop and loop for analysis i = 0 while i<20: print 'procedure #' + str(i) distribution = 'NORMAL 0 ' + RMSE outname = 'rand' + str(i) arcpy.CreateRandomRaster_management(outpath, outname, distribution, DEMextent, 5) randrast = Raster(outpath + '\\' + 'rand' + str(i)) addrast = randrast + DEM i = i+1
before I added the code to carry out the map algebra in the while loop the create random raster tool would work every time. However, once the next two lines of code were added the createrandomraster tool fails to execute every other time (error 999999).
Does anyone know why this could be?