1

I have to add tilesize and compression type to the following code

import arcpy

arcpy.CopyRaster_management("c:/data/background.tif",
                           "c:/fdgb/CpRaster.gdb/fgdbRD","DEFAULTS",
                           "0","9","","","8_BIT_UNSIGNED")

How do I add these two lines to above code?

arcpy.env.compression ="NONE 75"
arcpy.env.tileSize ="0.1 0.1"
  • 1
    You should review the documentation. Neither of your environment settings is correct (NONE doesn't support a value, and tileSize is in pixels). The doc also has examples of how environment settings are used. – Vince Mar 20 at 10:15
1

I believe you can just type it before copy raster:

import arcpy
arcpy.env.compression ="NONE" #beware, if NONE, then there is no value

arcpy.env.tileSize ="256 256" # has to be in pixels

arcpy.CopyRaster_management("c:/data/background.tif",
                           "c:/fdgb/CpRaster.gdb/fgdbRD","DEFAULTS",
                           "0","9","","","8_BIT_UNSIGNED")

compression value is only available for:

Compression quality (1-100)—When JPEG, JPEG_YCbCr, JPEG2000
compression is chosen, the compression quality also needs to be specified. 
The valid compression quality value ranges are from 1 to 100, with 75 being the default.

For the rest, use only:

arcpy.env.compression ="LZW"

update:

>>> arcpy.env.compression = 'NONE'
>>> arcpy.CopyRaster_management("nieder_00005.tif", r'C:\temp\tif.tif') 
<Result 'C:\\Temp\\tif.tif'>

>>> dsc = arcpy.Describe(tif.tif)
>>> dsc.compressionType
u'None'

>>> dsc_old = arcpy.Describe('nieder_00005.tif')
>>> dsc_old.compressionType
u'LZW'
  • Its not working, still the compression is in "LZW". it is not converted to "NONE" – Krishna Mar 20 at 10:39
  • I updated my answer, it is working. Just checked it with a random raster. – Jan Doležal Mar 20 at 10:49
  • If you still can not get it to work. Set output to a file, not to a database. I am not sure, if there are any settings in gdb, that are overriding the environments – Jan Doležal Mar 20 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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