AnsweredAssumed Answered

Why is this code does not work

Question asked by ajmna1988 on Jul 31, 2018
Latest reply on Jul 31, 2018 by jborgion

I am tring to warb many rasters to others using python in ArcMap, But I field, I need help.

I have two workspaces, because first contain many rasters with correct coordinate , and second workspace contain rasters with incorrect coordinate .

I need to warb rasters in socand worksapce to rasters in first workspace.

 

 

import arcpy

i = 0


while i <= 1:

inRasterworkspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI_R'
#inRasterworkspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = inRasterworkspace
inRasters = arcpy.ListRasters()
inRaster = inRasters[i]

SoTop=arcpy.GetRasterProperties_management(inRaster , "TOP")
SoLeft=arcpy.GetRasterProperties_management(inRaster , "LEFT")
SoRight=arcpy.GetRasterProperties_management(inRaster , "RIGHT")
SoBottom=arcpy.GetRasterProperties_management(inRaster , "BOTTOM")
Source_pnt = '\''+ str(SoLeft) + ' ' + str(SoTop) + '\' ;' + str(SoRight) + ' ' + str(SoTop) + '\' ;' + str(SoLeft) + ' ' + str(SoBottom)+'\''

# ========================
taRasterworkspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI2018'
#taRasterworkspace = arcpy.GetParameterAsText(1)
arcpy.env.workspace = taRasterworkspace
taRasters = arcpy.ListRasters('*', 'jpg')
taRaster = taRasters[i]

TaTop=arcpy.GetRasterProperties_management(taRaster , "TOP")
TaLeft=arcpy.GetRasterProperties_management(taRaster , "LEFT")
TaRight=arcpy.GetRasterProperties_management(taRaster , "RIGHT")
TaBottom=arcpy.GetRasterProperties_management(taRaster , "BOTTOM")
Target_pnt = '\''+ str(TaLeft) + ' ' + str(TaTop) + '\' ;' + str(TaRight) + ' ' + str(TaTop) + '\' ;' + str(TaLeft) + ' ' + str(TaBottom)+'\''

# ========================
arcpy.env.workspace = r'C:\Users\AgmnDesk\Desktop\GooleImage\GI2018'
arcpy.env.overwriteOutput = True
arcpy.Warp_management(str(taRaster), Source_pnt, Target_pnt, str(taRaster[:-4])+'tif', "POLYORDER2", "BILINEAR")

# ========================
i = i + 1

Attachments

Outcomes