Manage output from Spatial Analyst tools in Map Algebra

Available with Spatial Analyst license.

The primary raster output of a Spatial Analyst Map Algebra expression is a Raster object. One of the most important behaviors of a Raster object is that when it is created as primary output from a Map Algebra expression, it references a temporary raster. Temporary data, unless it is explicitly saved, will be removed when the ArcGIS session or script ends.

Save a temporary raster

You can permanently save a temporary raster by using the save method on the Raster object. If the temporary data has a layer associated with it, you can also save the data through the layer's context menu or by saving the map document. These methods of saving are detailed below:

  1. You can save a temporary raster by using the save method. In the example below, the temporary output from the Slope tool is saved to the specified output folder.
    outraster = Slope("C:/Data/elevation") 
    outraster.save("C:/output/sloperaster")
    • Where the data is saved depends on what you enter in the save method and what workspace environments you have set.

      • When the full path, with dataset name, is specified, this location is where the permanent data will be saved.
      • If only a dataset name is specified, the location of the saved data is determined by the geoprocessing workspace environments.
        • If the scratch or the current workspace is set, the saved data will be saved to the location of the set workspace.
        • If both the current workspace and scratch workspace are set, the saved data will be saved to the current workspace.
        • If no workspace is set, an error will be returned.

    • If you want to persist the data where it is with its default name, call the save method without specifying a name, as shown in the following example:
      outraster.save()
    • The save method supports all output raster data formats supported by Spatial Analyst. In the following example, the raster save method is used to save data to a file geodatabase raster and to a TIFF format raster.
      outraster.save("C:/output/file_gdb.gdb/sloperaster")
      outraster.save("C:/output/sloperaster.tif")
  2. To save a temporary raster dataset associated with a map layer, save the map project. When the project is saved, the raster dataset saves to disk at its current location with its autogenerated name.

Raster object, layer, and dataset interaction

A Raster object references a raster dataset and, if used in a map display, may be associated with a raster layer in the table of contents. The relationships between the raster dataset, the Raster object, and the raster layer are maintained in most cases, but it is important to understand these relationships to work productively with Spatial Analyst Map Algebra.

For more information, see Interaction of the Raster object.

Related topics