# Batch raster projection conversion

I want to do a conversion from WCG to UTM for my 172 Raster. I can't use normal batch because I can't re-arrange again the order of raster in the Table of Content.

Because the result is a random name in the same folder, so I need to do Raster Projection Conversion without changing the name and extension, only the output folder.

How to Batch Raster projection conversion without changing a name and extension only changing the output folder?

Some of Python code:

import arcpy, sys

InFolder = r"c:\start"
OutFolder = r"c:\end"
OutSR = r"WGS_1984_UTM_Zone_50S"

arcpy.env.workspace = InFolder

for Ras in arcpy.ListRasters():
arcpy.ProjectRaster_management (InFolder + "\\" + Ras, OutFolder + "\\" + Ras,OutSR)

• Any possibility of doing this in python? You can right click on the tool and select batch but I don't know if that will change the name. – Michael Stimson Jun 6 '14 at 3:29
• No, It wont change the name, it generates random name that even different from the 1st raster and I cant rearange my table of content because that strange file name. – Rikudo Pain Jun 6 '14 at 3:32

Provided there is no geographic transformation:

import arcpy, sys

InFolder = sys.argv[1]
OutFolder = sys.argv[2]
OutSR = arcpy.SpatialReference(32750) # "WGS_1984_UTM_Zone_50S"

arcpy.env.workspace = InFolder

for Ras in arcpy.ListRasters():
arcpy.ProjectRaster_management (InFolder + "\\" + Ras, OutFolder + "\\" + Ras,OutSR)


Documentation for the tool project raster is here http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000007q000000

Instructions on how to make this into a new tool is here http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000022000000

For the parameters it's:

InFolder is folder/workspace
OutFolder is folder/workspace
OutSR is spatial reference


in that order.

The numbers for arcpy.SpatialReference is EPSG (google epsg and the name of the coordinate system). For WGS84 UTM south projections it is 327 and then the zone, so 51 is 32751, 49 is 32749, for WGS84 Geographic it is 4326.

• I'm sorry I'm not quite understand python, is it auto detect input projection? so for example my infolder = C:\start and outfolder=C:\end and my projection = – Rikudo Pain Jun 6 '14 at 4:00
• yes, if the projection is defined for the input images all you need do is supply the output projection. Way back in the ArcINFO days you had to supply both input and output and that sometimes lead to data being totally destroyed. Define spatial reference can be batched if it's not set already. – Michael Stimson Jun 6 '14 at 4:04
• updated question, I try to input in pyton toolbox, but it's running and do nothing... now there are X mark in python toolbox – Rikudo Pain Jun 6 '14 at 4:09
• by nothing do you mean that no outputs are being created. The script should print the names of the rasters as it goes, is that happening? – Michael Stimson Jun 6 '14 at 4:12
• your code is incorrect: "c:\start" = sys.argv[1] is not right, it should be InFolder = r"c:\start"... it's set variable = value. Please read the links, they will show you how to make this into a tool. – Michael Stimson Jun 6 '14 at 4:14

Actually, the proper code is:

import arcpy, sys
InFolder = r"G:\SMGS\rektyfikowane"
OutFolder = r"G:\SMGS\transformed"
OutSR = arcpy.SpatialReference(2180)
arcpy.env.workspace = InFolder
for Ras in arcpy.ListRasters():

There is new spatial reference code where you need to input the EPSG number of coordinate system arcpy.SpatialReference(2180).