Timer unit: 4.27655e-07 s Total time: 1049.78 s File: c:\users\obrien\Dropbox\Teaching_PSU\Geog489_SU_1_18\Lesson 1\Lesson1B_basic_raster_for_mp.py Function: processRasters at line 24 Line # Hits Time Per Hit % Time Line Contents ============================================================== 24 @profile 25 def processRasters(): 26 # Get a list of rasters in my folder 27 1 67149699.0 67149699.0 2.7 rasters = arcpy.ListRasters("*") 28 1 1283.0 1283.0 0.0 new_rasters = filter_list(rasters,wildCardList) 29 30 # for all of our rasters 31 27 1386.0 51.3 0.0 for raster in new_rasters: 32 # Now that we have our list of rasters 33 26 318046.0 12232.5 0.0 arcpy.CheckOutExtension("Spatial") 34 ## Note also for performance we're not saving any of the intermediate rasters - they will exist only in memory 35 ## Fill the DEM to remove any sinks 36 26 405.0 15.6 0.0 try: 37 26 526508347.0 20250321.0 21.4 FilledRaster = Fill(raster) 38 ## Calculate the Flow Direction (how water runs across the surface) 39 26 347907554.0 13381059.8 14.2 FlowDirRaster = FlowDirection(FilledRaster) 40 ## Calculate the Flow Accumulation (where the water accumulates in the surface) 41 26 818959719.0 31498450.7 33.4 FlowAccRaster = FlowAccumulation(FlowDirRaster) 42 ## Convert the Flow Accumulation to a Stream Network 43 ## We're setting an arbitray threshold of 100 cells flowing into another cell to set it as part of our stream 44 ## http://pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/identifying-stream-networks.htm 45 26 439032768.0 16885875.7 17.9 Streams = Con(FlowAccRaster,1,"","Value > 100") 46 ## Convert the Raster Stream network to a feature class 47 26 2756.0 106.0 0.0 output_Polyline = raster.replace(".img",".shp") 48 26 220207.0 8469.5 0.0 arcpy.CheckOutExtension("Spatial") 49 26 250266078.0 9625618.4 10.2 arcpy.sa.StreamToFeature(Streams,FlowDirRaster,output_Polyline) 50 26 99808.0 3838.8 0.0 arcpy.CheckInExtension("Spatial") 51 except: 52 print ("Errors occured") 53 print (arcpy.GetMessages()) 54 arcpy.AddMessage ("Errors occurred") 55 arcpy.AddMessage(arcpy.GetMessages()) 56 57 finally: 58 26 1888122.0 72620.1 0.1 arcpy.AddMessage("--- %s seconds ---" % (time.time() - start_time)) 59 26 2384879.0 91726.1 0.1 print ("--- %s seconds ---" % (time.time() - start_time)) 60 61 # Output how long the process took. 62 1 2438.0 2438.0 0.0 arcpy.AddMessage("--- %s seconds ---" % (time.time() - start_time)) 63 1 1707.0 1707.0 0.0 print ("--- %s seconds ---" % (time.time() - start_time))