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 (GDA94z50) 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\\western_australia\\carnarvon_tsunami_scenario\\" |
---|
25 | output_dir="anuga\\outputs\\" |
---|
26 | |
---|
27 | ##time_dir1 = '20081209_155247_run_final_0_27255_250m_none_lfountai' |
---|
28 | ##time_dir2 = '20081209_161626_run_final_0_68693_250m_none_lfountai' |
---|
29 | ##time_dirs = [time_dir1, time_dir2] |
---|
30 | |
---|
31 | |
---|
32 | ##time_dir1 = '20081202_084220_run_final_1_27283_alpha0.1_kvanputt' |
---|
33 | ##time_dir2 = '20081202_084202_run_final_1_27255_alpha0.1_kvanputt' |
---|
34 | ##time_dir3 = '20081202_084132_run_final_1_68693_alpha0.1_kvanputt' |
---|
35 | time_dir4 = '20081202_084025_run_final_0_68693_alpha0.1_kvanputt' |
---|
36 | time_dir5 = '20081202_083932_run_final_0_27255_alpha0.1_kvanputt' |
---|
37 | ##time_dir6 = '20081201_103449_run_final_0_27283_alpha0.1_kvanputt' |
---|
38 | ## |
---|
39 | time_dirs = [time_dir4, time_dir5] #, time_dir3, time_dir4, time_dir5, time_dir6] |
---|
40 | |
---|
41 | for time_dir in time_dirs: |
---|
42 | |
---|
43 | # Local variables... |
---|
44 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
45 | raster_gbd = folder + 'raster.gdb' |
---|
46 | land = scenario_dir + "map_work\\Carnarvon.gdb\\land_initial_condition_all" |
---|
47 | ocean = scenario_dir + "map_work\\Carnarvon.gdb\\ocean_initial_condition" |
---|
48 | |
---|
49 | ## print 'Process: Create File GDB' |
---|
50 | ## gp.CreateFileGDB_management(folder, "raster") |
---|
51 | |
---|
52 | gp.Workspace = raster_gbd |
---|
53 | |
---|
54 | print time_dir |
---|
55 | |
---|
56 | #replication dictionary |
---|
57 | replicate = (('carnarvon', ''),#('time_39900_0', 'b'), ('time_79800_0', 'c'), |
---|
58 | ('_', ''), ('max','_M'), ('depth','_dep_'), |
---|
59 | ('speed', '_speed_'), ('elevation', '_ele_'), ('stage','_stage')) |
---|
60 | |
---|
61 | generate_filename = [] |
---|
62 | input_ascii = glob.glob(folder + '*stage_max.asc') |
---|
63 | |
---|
64 | for infile in input_ascii: |
---|
65 | output_DEM = os.path.basename(infile)[:-4] |
---|
66 | for (key, rep) in replicate: |
---|
67 | output_DEM = output_DEM.replace(key,rep) |
---|
68 | output_DEM = output_DEM[:10] |
---|
69 | if output_DEM in generate_filename: |
---|
70 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
71 | sys.exit(10) |
---|
72 | generate_filename.append(output_DEM) |
---|
73 | print 'Output DEM ',output_DEM |
---|
74 | |
---|
75 | print 'Process: ASCII to Raster' |
---|
76 | gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT") |
---|
77 | |
---|
78 | print 'Process: Define Projection' |
---|
79 | gp.DefineProjection_management(output_DEM,"PROJCS['GDA_1994_MGA_Zone_49',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994'" |
---|
80 | ",SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0]" |
---|
81 | ",UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator']" |
---|
82 | ",PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0]" |
---|
83 | ",PARAMETER['Central_Meridian',111.0],PARAMETER['Scale_Factor',0.9996]" |
---|
84 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
85 | |
---|
86 | |
---|
87 | ## print 'Process: Extract by Mask' |
---|
88 | ## output_extract = output_DEM + '_E' |
---|
89 | ## print 'Output Extract ',output_extract |
---|
90 | ## gp.ExtractByMask_sa(output_DEM, ocean, output_extract) |
---|
91 | |
---|
92 | |
---|