Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a couple of ArcGIS extensions that are running a lot of geoprocessing models with a mix of ArcObjects. I've noticed that the some, as of yet unidentified, geoprocessing steps are creating temporary raster files (e.g. g_g193, g_g983, g_g892). The funny thing is, these files are not being directed to my selected temporary workspace or the default Arc workspace. They are actually being sent to the 'bin' folder of my extension, which is obviously an issue since these temp files should not be stored with my included DLLs and EXE files.

It's important to mention that my extension makes many calls to Arc geoprocessing, so it's difficult to location the source of these files. The interesting thing is, if I walk through all of my code using break points in .NET these files don't always get created. It's like Arc is not cleaning up these temp files if the processing is moving very quickly, but it will clean them up if given time (e.g. user steps through slowly). Regardless, I don't want these files anywhere near my 'bin' folder.

Any insight would be greatly appreciated!

share|improve this question
there is a gpcleanup process now. – Brad Nesom Oct 13 '11 at 18:40
It looks like these may be generated when "map algebra" is used. Still need to delve further into this issue. – Nick O Oct 13 '11 at 18:42
@Brad - is there documentation on this process? A quick google search didn't yield anything relevant to Arc. – Nick O Oct 13 '11 at 18:43
So, it looks like in Arc10 Map Algebra relies on the python module - it appears that the environment.workspace method is different from the standard Spatial Analyst tools, in which I have temp workspaces set. Now I need to sort out how to set this workspace in .NET. Some basic info:… – Nick O Oct 13 '11 at 18:54
The only other thing I know about it is that Esri said that for most processes it happens automatically now. (not sure what sp# that is true with.) Also not sure what module or tools that is true for. – Brad Nesom Oct 13 '11 at 19:31
up vote 3 down vote accepted

Sorted this out, finally.

Map Algebra and other Spatial Analyst operations that do not explicitly invoke the Geoprocessor object have an environment setting (IRasterAnalysisEnvironment) different from that of the standard GP.Environment. This environment must be set, or else it will default to the location of the extension (e.g. the binary folder). You'd think it would use the same default geodatabase as the other Spatial Analyst tools, but this is clearly not the case.

Here is a simple example from the ESRI documentation.

    Public Sub UsingRasterMapAlgebra()
    'Get rasters.
    Dim inRas01 As IRasterDataset
    inRas01 = OpenRasterDataset("c:\temp", "degs")
    Dim inRas02 As IRasterDataset
    inRas02 = OpenRasterDataset("c:\temp", "negs")
    'Create RasterMapAlgebraOp.
    Dim mapAlgebraOp As IMapAlgebraOp
    mapAlgebraOp = New RasterMapAlgebraOpClass()
    'Set environment.
    Dim env As IRasterAnalysisEnvironment
    env = mapAlgebraOp
    Dim workspaceFactory As IWorkspaceFactory = New RasterWorkspaceFactoryClass()
    Dim workspace As IWorkspace = workspaceFactory.OpenFromFile("c:\temp", 0)
    env.OutWorkspace = workspace
    'Bind rasters.
    mapAlgebraOp.BindRaster(inRas01, "Ras01")
    mapAlgebraOp.BindRaster(inRas02, "Ras02")
    'Execute script.
    Dim rasOut As IRaster
    rasOut = mapAlgebraOp.Execute("[Ras01] + [Ras02]")
    'Save output raster.
    Dim saveAs As ISaveAs2
    saveAs = rasOut
    saveAs.SaveAs("outMA", workspace, "GRID")
End Sub
share|improve this answer
I have never tried it with ArcObjects or Spatial Analyst, but have you tried saving your temporary files to the in_memory workspace (ie- "in_memory\file") that is available with other geoprocessing tools?… – RyanDalton Oct 18 '11 at 14:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.