Select to view content in your preferred language

Export Data arcpy command line to save Tiff raster with zero compression

5072
10
07-30-2018 09:49 AM
SondraRobinson
New Contributor II

Hi guys. I have a script which cycles through a directory and adds 4band data. It works like a charm. The problem is that the customer wants the results UNcompressed. By default, all of the resulting files are compressed and so I have to manually open each file and then simply export data/raster to raster/compression set to zero. That works, but it's tedious and unnecessarily expensive in time.

I have looked everywhere I can to find out how to do the export process with zero compression by script. No luck, so I figured I'd try here.

Below is the currently functioning script.

----------------------------------------------------

import os,arcpy,glob

rasterpath = r"filepath-source"
outFolder = r"filepath-end"

arcpy.env.workspace = rasterpath

for rasterFile in arcpy.ListRasters("*.tif"):
    oName, oExt = os.path.splitext(rasterFile)
    outRaster = os.path.join(outFolder, oName+ ".tif")
    arcpy.CopyRaster_management(rasterFile,outRaster,"DEFAULTS","255","255","","","8_BIT_UNSIGNED")

-------------------------------------------------------

I know that the process of adding the band data creates pyramids, but my attempts to add zero compression to the environment on this script fails. What I'm looking for help with:

* the command line which will simply resave the data as-is but with no compression.

Compression is not an option for arcpy.CopyRaster_management in tiff format that I can find. There has to be a way to automate this. I'll be shooting myself if I have to manually open and resave hundreds of ortho images per object just for that single variable. I hope you guys can help! Thanks.

10 Replies
SondraRobinson
New Contributor II

Thank you! I had add this as a second script. So the first script adds the 4-band data and does what it needs to do [CopyRaster_management(rasterFile,outRaster,"DEFAULTS","255","255","","","8_BIT_UNSIGNED")]. This second script with then resaves everything without the compression exactly as you have it. You saved my sanity!!!!!

0 Kudos