Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. try:
  2. arcpy.env.workspace = r"Y:GISStudents_2013_14Winter_2014PRESCOTT_JOSHUA_BPYTHONweek6_midtermGIS255 midtermTahoe.gdb"
  3. clippedrast = "arowner"
  4.  
  5. allrasters = arcpy.ListRasters()
  6.  
  7. for soilrasters in allrasters:
  8. ##check for existence of output rasters here##
  9. if soilrasters == clippedrast:
  10. print "Checking rasters"
  11. elif soilrasters == (soilrasters[0:2]+"owner"):
  12. print soilrasters + " Output already exists"
  13. elif soilrasters[-4:]== "soil":
  14. arcpy.Clip_management(clippedrast, "#", soilrasters[0:2]+"owner", soilrasters)
  15. print "Finished clipping " + clippedrast + " to " + soilrasters + ". Name of output raster is " + soilrasters[0:2]+"owner."
  16. else:
  17. print "n"
  18.  
  19.  
  20. # except statement#
  21. except Exception as e:
  22. print "Script Failed"
  23. print e.message
  24. print "n"
  25.  
  26. # except statement to print out any geoprocessing errors
  27. except:
  28. print arcpy.GetMessages(2)
  29.  
  30. # else statement to print out results
  31. else:
  32. print "n"
  33. print "Script finished successfully"
  34. print "n"
  35. print "****RESULTS****"
  36. print arcpy.GetMessages(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement