Skip to content

Export from .tif to .tif with another CRS

I write a code in python for processing some .tif files and put them to WGS 1984 Coordinate System. The problem is, when I run the code, it gave’s me error and stop executing. I try to do this with arcpy.ProjectRaster_management for almost 100 .tif files. Could you help me to make this script to run? Bellow is the script that I have been written:

import arcpy
import os
import sys
import getpass

username = getpass.getuser()
empty_folder = os.path.expanduser("~") + r"Desktopwgs " + str(username)
path1 = empty_folder
if not os.path.exists(path1):

path2 = r"f:proiecteF5Robert NicolescuARCGISgeoreferentiereTEST_georeferentiereFINALE50GHAglobal_mapper_export"
tif_files = []
for x in os.listdir(path2):
    if x.endswith(".tif"):

input_coordinate_system = "WGS_1984_UTM_zone_29N"
output_coordinate_system = "GCS_WGS_1984"
resampling_technique = "NEAREST"

def projectRaster(input, output):
    arcpy.ProjectRaster_management(input,output,output_coordinate_system,resampling_technique, "","", "", input_coordinate_system)
    print "Script done!"

projectRaster(input=tif_files, output=path1)



Use the Model Builder within ArcGIS Desktop, once your model is done then export the Python code. What you are trying to do can be done using the Model Builder tool. Unless you want some extra ordinary functionality then you use modified code.

User contributions licensed under: CC BY-SA
10 People found this is helpful