AnsweredAssumed Answered

ArcPy: Working with temporary rasters...

Question asked by mmilner on Aug 10, 2015
Latest reply on Aug 10, 2015 by mmilner

I'm new to GeoNet (and ArcPy)...

 

I wrote a script that will eventually be turned into a script tool. For now the code:

Creates a point (X)

Extracts values for that point from multiple grids (X)

Assigns the extracted grid values to variables (X)

For each grid...

Uses the extracted value of that grid (stored in a variable) to define an inference space for the grid (X)

Sets non-inference space cells to nulls

Creates a comprehensive inference space by adding all the grids together

Converts final inference space to a polygon

Selects field sites associated with the polygon

Saves the selected field sites' model parameters to an Excel file.

 

I can run each line one at a time from within the Python Window, but I can't run the code as a script loaded into the Python Window. When the code reaches the first SetNull command it generates the output AND errs out.

 

# Calculate each grid's inference space using Charlie's rules. Begin with ai

airast = arcpy.Raster("aikm")

if aikm < 6000:

    outairast = (airast > (aikm - 1000))*(airast < (aikm + 1000))

else:

    outairast = airast > 5000

# Set false (i.e. zero) values to null

outai_setnull = SetNull("outairast", "outairast", "VALUE < 1")

 

I set my workspace to the input grid location. I do not want the output to go to that folder. The temporary rasters are being stored in my Default.gdb.

 

Do I need to save (and then delete) outairast and outai_setnull in order for the script to work? If so... that doesn't sound very efficient.

Outcomes