Home > Enterprise >  Export from .tif to .tif with another CRS
Export from .tif to .tif with another CRS

Time:02-13

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"\Desktop\wgs "   str(username)
path1 = empty_folder
if not os.path.exists(path1):
    os.makedirs(path1)


path2 = r"f:\proiecte\F5\Robert Nicolescu\ARCGIS\georeferentiere\TEST_georeferentiere\FINALE\50GHA\global_mapper_export"
tif_files = []
for x in os.listdir(path2):
    if x.endswith(".tif"):
        tif_files.append(x)


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)

CodePudding user response:

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.

  • Related