How to batch export a bunch of rasters to .tif format

12566
2
08-23-2010 07:48 AM
jimparsons1
New Contributor
Problem two for the day: I'm using the Copy Raster tool to try to export a bunch of ESRI grids to tif. When I right click in the batch view of Copy Raster I get the attached image. How do I set it up so that the images export to .tif?

If I leave the output raster column empty for some reason it defaults to .img. This is strange, as this isn't an ESRI format. I haven't found an environment setting to prevent rasters (happens in other tools as well) defaulting to Erdas format.

So I need to specify I want a .tif, without having to manually edit every single raster output filename. Using 'fill' is no good becuase it duplicates the names. How can I teach the output column to ensure I get a tif, without having to type out every output filename? Thank you
0 Kudos
2 Replies
RobertBerger
New Contributor III
Hi Jim,

You can also make a multi-selection in ArcCatalog > Right-Click > Export > Raster to Different Format. Then use the tool to output the raster format (TIFF in your case) and the output workspace. This should make it a lot easier to convert a lot of images to a single format.
Hope this helps.

Robert
0 Kudos
DarylVan_Dyke
New Contributor III
Hi-

It would seem that a good, scriptable approach for this would be with a list driven call in a Python script using "copy_managment()" method.
I should be able to append the ".tif" to the output raster name, and get TIFFs.

This is not my experience .... redundant print statements strongly indicate that the gp.Copy_Management call is getting the proper syntax, but I'm still getting only GRIDs on the other side.

Any ideas?  Kudos for the R-click batch converter tip!

Daryl

# ---------------------------------------------------------------------------
# Grids to Tiffs
# Created on: Fri Aug 20 2010 03:15:43 PM
#   Daryl Van Dyke, USFWS Klamath SHC Analyst
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)

# Check out any necessary licenses
gp.CheckOutExtension("spatial")

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
gp.OverwriteOutput = 1


# Local variables...
TileSet = "G:\\02_Shasta\\DEM_Tile\\"
targetDirectory = "J:\\DEM_tif\\"

gp.Workspace = TileSet
listRasters = gp.ListRasters( "", "")
print "Workspace: "+ TileSet
print listRasters
for rasters in listRasters:
    print "copying "+rasters+" to "+targetDirectory+rasters+".tif"+" from "+TileSet
    outputLocation = targetDirectory+rasters+".tif"
    print outputLocation
    print "gp.Copy_Management("+rasters+","+outputLocation+")"
    gp.Copy_Management(rasters, outputLocation,"#","#","#","NONE","NONE","#")


example print output:
J:\DEM_tif\r257.tif
gp.Copy_Management(r257,J:\DEM_tif\r257.tif)
copying r258 to J:\DEM_tif\r258.tif from G:\02_Shasta\DEM_Tile\
J:\DEM_tif\r258.tif
gp.Copy_Management(r258,J:\DEM_tif\r258.tif)
copying r259 to J:\DEM_tif\r259.tif from G:\02_Shasta\DEM_Tile\

etc...
0 Kudos