I have two rasters (an ESRI grid and an IMAGINE image) that differ in projection, extent and cell size. I want to convert the IMAGINE to an ASCII, and want it to have the extent, cell size and projection of the ESRI grid. I've set global environment variables (extent, output CRS, cell size, snap raster) to match the values in the ESRI grid, and the ASCII that results from RasterToASCII_conversion has the correct projection and extent, but ignores the cell size setting.

However, if I use the Raster and ApplyEnvironment tools (see code below) from the Python console, the output is as expected (correct cell size, extent, etc).

import arcpy
arcpy.env.extent = 'c:/path/to/grid'
arcpy.env.cellSize = 'c:/path/to/grid'
arcpy.env.outputCoordinateSystem = 'c:/path/to/grid'
arcpy.env.snapRaster = 'c:/path/to/grid'
r = arcpy.Raster('c:/path/to/imagine')
rclip = arcpy.sa.ApplyEnvironment(r)

While I could do the above and then convert the resulting grid to ASCII, I'd prefer to do the whole procedure without using Spatial Analyst. Is this possible?

I'm using ArcGIS 10.

1 Answer 1


Even within Arcmap, you have to set the settings within the Environments tab of the tool being used in Arctoolbox, otherwise the cell size is set the 1/250th of the maximum of the extent (width/height maximum). There is no default to the defaults and your procedure seems fine...seems that you could create a simple tool to simply the workflow without having to replace the paths in multiple lines.

  • So, there's no way to set the cell size environment variable with Python, and get RasterToASCII_conversion to pay attention to it? I had thought that setting the arcpy.env. variables would do the trick. Is there another group of env variables that needs to be set? Ideally, I'd like to process these rasters with Python, and avoid Spatial Analyst.
    – jbaums
    Commented Jun 7, 2011 at 2:13

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.