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!

  • there is a gpcleanup process now.
    – Brad Nesom
    Commented Oct 13, 2011 at 18:40
  • It looks like these may be generated when "map algebra" is used. Still need to delve further into this issue.
    – Radar
    Commented Oct 13, 2011 at 18:42
  • @Brad - is there documentation on this process? A quick google search didn't yield anything relevant to Arc.
    – Radar
    Commented Oct 13, 2011 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: help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/…
    – Radar
    Commented Oct 13, 2011 at 18:54
  • 1
    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
    Commented Oct 13, 2011 at 19:31

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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