Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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

When creating a raster map algebra output, is it possible to set its compression? I'm creating a model which generates many hundreds of rasters, and currently each is being stored without any compression which quickly adds up. I expected to be able to use arcpy.env.compression but that seems to have no effect. Example script which produces this behavior:

import arcpy

arcpy.env.compression = 'LZW' # supported by GeoTIFF and most packages

map = Raster("raster.tif") + 100"raster_plus_100.tif") # would expect this output to have compresssion
share|improve this question
Does it have anything to do with LZW being proprietary? I have used this reference for my decision-making in regard to image format...… – Brad Nesom Feb 10 '11 at 20:09
Maybe with this added... – Brad Nesom Feb 10 '11 at 20:21
The patents on LZW expired about 7 years back, but I can't get it to work with other compression methods either. – scw Feb 10 '11 at 21:37
up vote 5 down vote accepted

I think the problem is that arcpy.env settings only apply to tools. Calling a method on an object is not technically a "tool". In a practical sense, the arcpy.env settings should apply to stuff like but it doesn't appear to work that way.

I was able to save a raster with compression by using arcpy.CopyRaster_management(). Something like this:

arcpy.env.compression = 'LZW'
t1 = arcpy.Raster('sample.tif') + 100
arcpy.CopyRaster_management(t1, 't1.tif')
del t1
share|improve this answer

Try using ApplyEnvironment on the raster variable.

#convert raster form meter to feet
raster = arcpy.Raster(raster_path) * 0.3048
arcpy.env.compression = 'LZW'
compressedRaster =
share|improve this answer
Hi James, thanks for the tip. I couldn't seem to get it to work with GeoTIFF files, but perhaps I missed a step. – scw Feb 16 '11 at 23:42

I don't think it is what you are looking for, I think it if for unicode strings

>>> dir(arcpy.env.compression) ... ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'islower', 'isnumeric', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

share|improve this answer
Hi Dan, the dir above shows the methods available to the current value of arcpy.env.compression, which is a string, so I don't think this gets us very far, but thank you for looking into it. – scw Feb 10 '11 at 23:24
Found that out shortly after Mr Downvote appeared without comment, in any event, it should have provided more than the unicode input stuff, but a list of acceptable values...had to get those from the online esri help at… for future reference – Dan Patterson Feb 11 '11 at 18:09

I see a double quote in the online example...
arcpy.env.compression = "LZW"

share|improve this answer
It's python...single and double quotes are treated the same. – Derek Swingley Feb 10 '11 at 23:22

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.