Guest User

Untitled

a guest
Dec 16th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. # Import system modules
  2. import arcpy
  3. from arcpy import env
  4.  
  5. # enable overwrite outputs
  6. arcpy.env.overwriteOutput = True
  7.  
  8. # input feature directory: yr0_transects
  9. dir_yr0_transects = r"W:Workingabcdefg_workingPointDistancedatapoint_distanceyear0outputoutput_year0.gdb"
  10.  
  11. # input feature directory: yr1_transects
  12. dir_yr1_transects = r"W:Workingabcdefg_workingPointDistancedatapoint_distanceyear1outputoutput_year1.gdb"
  13.  
  14. # output directory
  15. outWorkspace = r"W:Workingabcdefg_workingProfiles"
  16.  
  17. # Create list of year 0 Transect features
  18. arcpy.env.workspace = dir_yr0_transects
  19. yr0_transects_list = sorted(arcpy.ListFeatureClasses())
  20.  
  21. # Create list of year 1 Transect features
  22. arcpy.env.workspace = dir_yr1_transects
  23. yr1_transects_list = sorted(arcpy.ListFeatureClasses())
  24.  
  25. # Set workspace
  26. arcpy.env.workspace = r"W:Workingabcdefg_workingProfiles"
  27.  
  28. # Set local variables
  29. graph_tee = r"W:Workingabcdefg_workingProfilesProfile_graph_template.tee"
  30.  
  31.  
  32.  
  33. for yr0_transect, yr1_transect in zip(yr0_transects_list, yr1_transects_list):
  34. try:
  35. #Cast to string because ListFC() returns unicode.
  36. string_yr0_transect = str(yr0_transect)
  37. string_yr1_transect = str(yr1_transect)
  38.  
  39. # create title for graph
  40. graph_title = "Profiles, B.F.E." + string_yr0_transect[0:17] + string_yr0_transect[47:]
  41.  
  42.  
  43. # Create the graph object
  44. graph = arcpy.Graph()
  45.  
  46. # Add a vertical bar series to the graph
  47. graph.addSeriesLineVertical(yr0_transect)
  48. graph.addSeriesLineVertical(yr1_transect)
  49.  
  50. # Specify the title of the Graph
  51. graph.graphPropsGeneral.title = graph_title
  52.  
  53. # Create graph output name
  54. output_graph_name = string_yr0_transect[0:17] + string_yr0_transect[47:] + "_profile" + ".png"
  55.  
  56. # Output a vertical line graph, which is created in-memory
  57. arcpy.MakeGraph_management(graph_tee, graph, "temp_graph")
  58.  
  59. #Execute SaveGraph
  60. mygraph = arcpy.SaveGraph_management("temp_graph", output_graph_name, "MAINTAIN_ASPECT_RATIO", "1024", "768")
  61.  
  62. del mygraph
  63.  
  64. except:
  65. print arcpy.GetMessages()
Add Comment
Please, Sign In to add comment