Ticket #505 (closed Defect: fixed)
Sample Rasters tools fail with ArcGISError: Failed to set the ScratchWorkspace property of ArcGIS Geoprocessor object ... to None.
|Reported by:||jjr8||Owned by:||jjr8|
|Component:||Tools - Spatial Analysis||Version:|
A more complete error message looks like this:
ArcGISError: Failed to set the ScratchWorkspace property of ArcGIS Geoprocessor object 0x1358D148 to None. This may result from a problem with your inputs or it may indicate a programming mistake in this tool or ArcGIS itself. Please check your inputs and try again. Also review any preceding error messages and the detailed error information that appears at the end of this message. If you suspect a programming mistake in this tool or ArcGIS, please contact the author of this tool for assistance. Detailed error information: The following exception was raised when the property was assigned: COM Error 0x80004005: "Unspecified error". The following consequences resulted from the original error: Sampling failed.
The problem occurs on releases of ArcGIS 9.3 prior to 9.3.1 SP1. It is a regression introduced in MGET 0.8a26.
The problem relates to the fact that, on this version of ArcGIS, the tool must instantiate the geoprocessor with COM automation rather than the arcigsscripting module, due to the problem described in #152. But in r781, released in MGET 0.8a26, I modified the ArcGIS geoprocessor wrapper as described in this comment from the code:
# Before invoking the method, check whether it is a Spatial # Analyst tool, which is indicated by it ending in "_sa". If # it is, create a temp directory and set the ScratchWorkspace # to it. # # We do this because some Spatial Analyst tools, particularly # the Map Algebra tools, create temporary ArcInfo binary grids # as part of their processing, but they do not delete them # upon completion. These will accumulate in the user's TEMP # directory unless a ScratchWorkspace has been set. Once # several thousand exist, the Spatial Analyst tools will stop # working (ArcCatalog or ArcMap will crash) until they are # deleted. # # Users typically encounter this only after running several # thousand Spatial Analyst tools without logging off. Windows # deletes the contents of the TEMP directory at logoff. # Nonetheless, certain batch jobs, such as converting # thousands of HDFs to rasters, are common scenarios for # GeoEco users so we must protect them from this problem.
After the Spatial Analyst tool completes, the ArcGIS geoprocessor wrapper sets the ScratchWorkspace to what it was before, which is often None. Apparently the COM-based geoprocessor does not like that.
The geoprocessor wrapper already translates None to '' when setting attributes of the geoprocessor instantiated by arcgisscripting. I will change it to always translate None to '', regardless of how the geoprocessor was instantiated.