1 | # --------------------------------------------------------------------------- |
---|
2 | # Inundation_line.py |
---|
3 | # Created on: Tue May 12 2009 01:50:45 PM |
---|
4 | # (generated by ArcGIS/ModelBuilder) |
---|
5 | # Usage: Inundation_line <Bun_depth_M_E> <Bus_depth_M_E> <bunbury_1km> <busselton_1km> |
---|
6 | # --------------------------------------------------------------------------- |
---|
7 | |
---|
8 | # Import system modules |
---|
9 | import sys, string, os, arcgisscripting, glob |
---|
10 | |
---|
11 | # Create the Geoprocessor object |
---|
12 | gp = arcgisscripting.create() |
---|
13 | gp.overwriteoutput = 1 |
---|
14 | |
---|
15 | # Set the necessary product code |
---|
16 | gp.SetProduct("ArcInfo") |
---|
17 | |
---|
18 | # Check out any necessary licenses |
---|
19 | gp.CheckOutExtension("spatial") |
---|
20 | |
---|
21 | # Load required toolboxes... |
---|
22 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") |
---|
23 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") |
---|
24 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") |
---|
25 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx") |
---|
26 | |
---|
27 | # Script arguments... |
---|
28 | time_dir1 = '20090327_152717_run_final_0.6_27283_Bt_kvanputt' |
---|
29 | time_dir2 = '20090330_120458_run_final_0_27283_Bt_kvanputt' |
---|
30 | time_dir3 = '20090324_134328_run_final_0.6_27255_Bt_kvanputt' |
---|
31 | time_dir4 = '20090327_160646_run_final_0_27255_Bt_kvanputt' |
---|
32 | time_dir5 = '20090324_140747_run_final_0.6_68693_Bt_kvanputt' |
---|
33 | time_dir6 = '20090327_161520_run_final_0_68693_Bt_kvanputt' |
---|
34 | |
---|
35 | time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6] |
---|
36 | |
---|
37 | community = 'busselton' |
---|
38 | scenario = "\\\\nas2\\gemd\\georisk_models\\inundation\\data\\western_australia\\" + community +"_tsunami_scenario\\" |
---|
39 | output_folder = scenario + "anuga\\outputs\\" |
---|
40 | locations = ['bunbury', 'busselton'] |
---|
41 | |
---|
42 | for time_dir in time_dirs: |
---|
43 | |
---|
44 | raster = output_folder + time_dir + "\\raster.gdb\\" |
---|
45 | |
---|
46 | for location in locations: |
---|
47 | |
---|
48 | # Local variables... |
---|
49 | if location == 'bunbury': |
---|
50 | # polygon clip |
---|
51 | extent = scenario + "map_work\\Busselton.gdb\\internal_polygons\\bunbury_1km_clip" |
---|
52 | # name of rasters |
---|
53 | depth = raster + 'Bun_depth_M_E' |
---|
54 | |
---|
55 | elif location == 'busselton': |
---|
56 | # polygon clip |
---|
57 | extent = scenario + "map_work\\Busselton.gdb\\Internal_polygons\\busselton_1km_clip" |
---|
58 | # name of rasters |
---|
59 | depth = raster + 'Bus_depth_M_E' |
---|
60 | |
---|
61 | else: |
---|
62 | print 'No recognisable location entered' |
---|
63 | |
---|
64 | print 'location', location |
---|
65 | print 'extent', extent |
---|
66 | |
---|
67 | depth_raster = depth |
---|
68 | |
---|
69 | # Local variables... |
---|
70 | Output_raster = raster +"Temp_raster_"+ location |
---|
71 | Output_polygon_features = raster +"Temp_polygon_"+ location |
---|
72 | Output_Feature_Class = raster +"Temp_line_"+ location |
---|
73 | Reclassification = "0 0.05 NODATA;0.05 4.5840001106262207 1" |
---|
74 | Inundation = raster + "Inundation_" + location + "_polygon" |
---|
75 | Inundation_line = raster + "Inundation_line" |
---|
76 | |
---|
77 | print 'Process: Reclassify' |
---|
78 | gp.Reclassify_sa(depth, "Value", Reclassification, Output_raster, "DATA") |
---|
79 | |
---|
80 | print 'Process: Raster to Polygon' |
---|
81 | gp.RasterToPolygon_conversion(Output_raster, Output_polygon_features, "SIMPLIFY", "VALUE") |
---|
82 | |
---|
83 | print 'Process: Clip' |
---|
84 | gp.Clip_analysis(Output_polygon_features, extent, Inundation, "") |
---|
85 | |
---|
86 | print 'Process: Delete' |
---|
87 | gp.Delete_management(Output_raster, "RasterDataset") |
---|
88 | gp.Delete_management(Output_polygon_features, "FeatureClass") |
---|