# Why does order of commands in raster processing matter? [closed]

My company has recently changed to ArcGIS 10.5 (from 10.1) and now some arcpy scripts that worked fine before don't run anymore. I am not completetly convinced this is actually the reasons of the problem, or whether the data/projection is somehow special but here it goes:

MWE:

import arcpy

arcpy.CheckOutExtension('Spatial')

def create_polyoutline(raster):
print "creating outline for " + str(raster)
ras = arcpy.CreateUniqueName("ras_int")
arcpy.gp.Reclassify_sa(raster,"Value","0 9999999 1",ras,"DATA")
arcpy.Delete_management(ras)

arcpy.env.workspace  = r"Z:\\"

in_ = r"Z:\ref\d_max_a.tif"
poly = create_polyoutline(in_)
in_ = r"Z:\ref\d_max_b.tif"
poly = create_polyoutline(in_)


this works if i first process grid "d_max_a.tif" and then "d_max_b.tif". But not the other way around.

The error is the following:

Traceback (most recent call last):
File "<module2>", line 17, in <module>
File "<module2>", line 8, in create_polyoutline
File "c:\program files (x86)\arcgis\desktop10.5\ArcPy\arcpy\geoprocessing\_base.py", line 510, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
This spatial reference object cannot be defined from the available information.
Failed to execute (Reclassify).


Both rasters have the same coordinate system assigned (CH1903+_LV95).

In other, more complex scripts the tool sometimes just fails with generic error 999999:

ExecuteError: ERROR 999999: Error executing function.
Failed to execute (Reclassify).


The 2 grids are basically the same, except for slightly different extents. The problem seems to always arise after processing several grids (not necesarilly 2). However the grid that causes the script to fail can always be processed individually, after restarting the script. Is there some kind of cache or in_memory magic at work, or why does the order of these 2 reclassify commands matter?

• Order of execution often impacts raster processing, but it's usually a speed issue, not a failure one. This is more something to address with Esri Tech Support, to whom you'll need to give the data, than anything with which we can help. – Vince Jul 7 '17 at 11:44
• This probably will not resolve the error but from a python readability point I would recommend not using the same "in_" and "poly" variable names twice (maybe use something like "rasterA" and "rasterB", AND "polyA" and "polyB"). – artwork21 Jul 7 '17 at 12:01