1 | # --------------------------------------------------------------------------- |
---|
2 | # Arc_extract_by_mask.py |
---|
3 | # Created on: Fri Jun 05 2009 12:09:58 |
---|
4 | # (generated by ArcGIS/ModelBuilder) |
---|
5 | # --------------------------------------------------------------------------- |
---|
6 | |
---|
7 | # Import system modules |
---|
8 | import sys, string, os, arcgisscripting, glob, os.path |
---|
9 | |
---|
10 | # Create the Geoprocessor object |
---|
11 | gp = arcgisscripting.create() |
---|
12 | |
---|
13 | # Check out any necessary licenses |
---|
14 | gp.CheckOutExtension("spatial") |
---|
15 | |
---|
16 | # Load required toolboxes... |
---|
17 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") |
---|
18 | gp.overwriteoutput = 1 |
---|
19 | |
---|
20 | scenario_dir="\\\\nas2\\gemd\\georisk_models\\inundation\\data\\new_south_wales\\gosford_tsunami_scenario_2009\\" |
---|
21 | output_dir = "anuga\\outputs\\" |
---|
22 | |
---|
23 | |
---|
24 | variable = 'speed' |
---|
25 | time_dir1 = '20090615_160527_run_final_1.0_51436_jgriffin' |
---|
26 | time_dir2 = '20090615_160610_run_final_0.0_51436_jgriffin' |
---|
27 | time_dir3 = '20090615_160900_run_final_0.0_58242_jgriffin' |
---|
28 | time_dir4 = '20090615_160939_run_final_1.0_58242_jgriffin' |
---|
29 | time_dir5 = '20090615_161039_run_final_0.0_58284_jgriffin' |
---|
30 | time_dir6 = '20090615_161145_run_final_0.0_58349_jgriffin' |
---|
31 | time_dir7 = '20090615_161318_run_final_0.0_58187_jgriffin' |
---|
32 | time_dir8 = '20090615_161339_run_final_0.0_58113_jgriffin' |
---|
33 | time_dir9 = '20090615_161420_run_final_0.0_58025_jgriffin' |
---|
34 | |
---|
35 | time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6, time_dir7, time_dir8, time_dir9] |
---|
36 | |
---|
37 | for time_dir in time_dirs: |
---|
38 | |
---|
39 | print time_dir |
---|
40 | |
---|
41 | #get event number |
---|
42 | time_dir_split = time_dir.split('_') |
---|
43 | event_number = time_dir_split[5] |
---|
44 | print 'event_number', event_number |
---|
45 | |
---|
46 | # Local variables... |
---|
47 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
48 | raster_gdb = folder + 'raster.gdb' |
---|
49 | |
---|
50 | gp.Workspace = raster_gdb |
---|
51 | |
---|
52 | print gp.Workspace |
---|
53 | |
---|
54 | #replication dictionary |
---|
55 | replicate = (('batemans_bay', ''), |
---|
56 | ('_', ''),('Geordie', 'Geo'),('Sorrento', 'Sor'), ('max','M_'), |
---|
57 | ('Fremantle', 'Fre'),('Rockingham', 'Roc'),('depth','_dep_'), |
---|
58 | ('speed', '_spe_'), ('elevation', '_ele_'), ('stage','_stage')) |
---|
59 | |
---|
60 | generate_filename = [] |
---|
61 | input_raster = raster_gdb + '\\All_spe_M_' |
---|
62 | #input_raster = glob.glob(raster_gbd + 'All_dep*') |
---|
63 | print 'input raster', input_raster |
---|
64 | |
---|
65 | output_raster = raster_gdb + '\speed_clip' |
---|
66 | print 'output_raster', output_raster |
---|
67 | |
---|
68 | # Local variables... |
---|
69 | #depth_58346_msl = "N:\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\outputs\\20090528_153025_run_final_0.0_58346_jgriffin\\raster.gdb\\depth_58346_msl" |
---|
70 | #speed_58346_msl = "N:\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\outputs\\20090528_153025_run_final_0.0_58346_jgriffin\\raster.gdb\\speed_58346_msl" |
---|
71 | #All_dep_M_ = "N:\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\outputs\\20090528_153025_run_final_0.0_58346_jgriffin\\raster.gdb\\All_dep_M_" |
---|
72 | #All_spe_M_ = "N:\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\outputs\\20090528_153025_run_final_0.0_58346_jgriffin\\raster.gdb\\All_spe_M_" |
---|
73 | ## aoi_land = "N:\\georisk_models\\inundation\\data\\new_south_wales\\gosford_tsunami_scenario_2009\\anuga\\polygons\\polygons.gdb\\aoi_umina_land_union" |
---|
74 | aoi_all = "N:\\georisk_models\\inundation\\data\\new_south_wales\\gosford_tsunami_scenario_2009\\anuga\\polygons\\polygons.gdb\\aoi_terrigal_umina_allarea_Union" |
---|
75 | |
---|
76 | # Process: Extract by Mask... |
---|
77 | print 'extracting by mask' |
---|
78 | gp.ExtractByMask_sa(input_raster, aoi_all, output_raster) |
---|
79 | |
---|
80 | # Process: Extract by Mask (2)... |
---|
81 | #gp.ExtractByMask_sa(All_spe_M_, aoi_all, speed_58346_msl) |
---|
82 | |
---|