raslist=arcpy.ListRasters()
for ras in raslist:
arcpy.ProjectRaster_management(ras,outfolder2+ras+'_Albers',spatialref2)
print ras+' has been reprojected'
I was using the above code for batch processing in "Project Raster". I want to add "_Albers" in the output file name for each file. But the third line doesn't work. if I delete the "_Albers" in the third line, it works. But I want to rename the output file.
Thanks.
Best Answer
Since you didn't share what "outputfolder2" variable is, you may have been forgetting to include the folder separator (ie- "\").
To use a bit more of a "Pythonic" way of creating your path/filename where you have to remember to force a folder/file separator, use
os.path.join
instead of the+
, but I also like using the strategy @David suggested: