1 | # --------------------------------------------------------------------------- |
---|
2 | # This python script is an ArcGIS script that can only be run on a computer |
---|
3 | # with and ArcGIS licence and version 2.4.1 python. |
---|
4 | # This script is designed to read in .asc files and deliever rasters with |
---|
5 | # projection (GDA94z56) held in a file geodatabase (called raster) |
---|
6 | # written by Kristy Van Putten and Ross Wilson |
---|
7 | # --------------------------------------------------------------------------- |
---|
8 | |
---|
9 | # Import system modules |
---|
10 | import sys, string, os, arcgisscripting, glob, os.path |
---|
11 | |
---|
12 | # Create the Geoprocessor object |
---|
13 | gp = arcgisscripting.create() |
---|
14 | |
---|
15 | # Check out any necessary licenses |
---|
16 | gp.CheckOutExtension("spatial") |
---|
17 | |
---|
18 | # Load required toolboxes... |
---|
19 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") |
---|
20 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") |
---|
21 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") |
---|
22 | gp.overwriteoutput = 1 |
---|
23 | |
---|
24 | scenario_dir="\\\\nas2\\gemd\\georisk_models\\inundation\\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\" |
---|
25 | output_dir = "anuga\\outputs\\" |
---|
26 | |
---|
27 | ##time_dir1 = '20081209_155431_run_final_0_27255_250m_none_lfountai' |
---|
28 | ##time_dir2 = '20081210_100528_run_final_0_68693_250m_none_kvanputt' |
---|
29 | ##time_dirs = [time_dir1, time_dir2] |
---|
30 | |
---|
31 | time_dir1 = '20090520_144937_run_final_0.0_58272_jgriffin' |
---|
32 | time_dir2 = '20090520_145453_run_final_0.0_58115_jgriffin' |
---|
33 | time_dir3 = '20090520_145156_run_final_1.0_58272_jgriffin' |
---|
34 | time_dir4 = '20090520_145208_run_final_0.0_51445_jgriffin' |
---|
35 | time_dir5 = '20090520_145510_run_final_0.0_58129_jgriffin' |
---|
36 | time_dir6 = '20090520_145608_run_final_0.0_58226_jgriffin' |
---|
37 | time_dir7 = '20090520_145616_run_final_0.0_58284_jgriffin' |
---|
38 | time_dir8 = '20090520_145700_run_final_0.0_58286_jgriffin' |
---|
39 | time_dir9 = '20090525_093040_run_final_1.0_51445_jgriffin' |
---|
40 | |
---|
41 | |
---|
42 | time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6, time_dir7, time_dir8, time_dir9] |
---|
43 | |
---|
44 | for time_dir in time_dirs: |
---|
45 | |
---|
46 | # Local variables... |
---|
47 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
48 | raster_gbd = folder + 'raster.gdb' |
---|
49 | #contour = raster_gbd + '\\contour_dep' |
---|
50 | #land = scenario_dir + "map_work\\Perth.gdb\\Outlines\\initial_conditions_rottnest" |
---|
51 | #ocean = scenario_dir + "map_work\\Perth.gdb\\Outlines\\initial_conditions_ocean1" |
---|
52 | |
---|
53 | print 'Process: Create File GDB' |
---|
54 | gp.CreateFileGDB_management(folder, "raster") |
---|
55 | |
---|
56 | gp.Workspace = raster_gbd |
---|
57 | |
---|
58 | print gp.Workspace |
---|
59 | |
---|
60 | #replication dictionary |
---|
61 | replicate = (('batemans_bay', ''), |
---|
62 | ('_', ''),('Geordie', 'Geo'),('Sorrento', 'Sor'), ('max','M_'), |
---|
63 | ('Fremantle', 'Fre'),('Rockingham', 'Roc'),('depth','_dep_'), |
---|
64 | ('speed', '_spe_'), ('elevation', '_ele_'), ('stage','_stage')) |
---|
65 | |
---|
66 | generate_filename = [] |
---|
67 | input_ascii = glob.glob(folder + '*max.asc') |
---|
68 | print time_dir |
---|
69 | |
---|
70 | for infile in input_ascii: |
---|
71 | output_DEM = os.path.basename(infile)[:-4] |
---|
72 | for (key, rep) in replicate: |
---|
73 | output_DEM = output_DEM.replace(key,rep) |
---|
74 | output_DEM = output_DEM[:10] |
---|
75 | if output_DEM in generate_filename: |
---|
76 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
77 | sys.exit(10) |
---|
78 | generate_filename.append(output_DEM) |
---|
79 | print 'Output DEM ',output_DEM |
---|
80 | |
---|
81 | print 'Process: ASCII to Raster' |
---|
82 | gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT") |
---|
83 | |
---|
84 | print 'Process: Define Projection' |
---|
85 | gp.DefineProjection_management(output_DEM, "PROJCS['GDA_1994_MGA_Zone_56',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]" |
---|
86 | ",PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',153.0],PARAMETER['Scale_Factor',0.9996]" |
---|
87 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | ## output_extract = output_DEM + 'E' |
---|
92 | ## print 'Output Extract ',output_extract |
---|
93 | ## |
---|
94 | ## print 'Process: Extract by Mask' |
---|
95 | ## gp.ExtractByMask_sa(output_DEM, land, output_extract) |
---|
96 | ## |
---|
97 | ## |
---|