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 | model = 'hobart' |
---|
25 | scenario_dir="\\\\nas2\\gemd\\georisk_models\\inundation\\data\\tasmania\\" + model + "_tsunami_scenario_2009\\" |
---|
26 | output_dir = "anuga\\outputs\\" |
---|
27 | |
---|
28 | time_dir1 = '20090505_150430_run_final_0.8_58292_None_kvanputt' |
---|
29 | time_dir2 = '20090505_150517_run_final_0_58292_None_kvanputt' |
---|
30 | time_dir3 = '20090505_150711_run_final_0_58280_None_kvanputt' |
---|
31 | time_dir4 = '20090505_150805_run_final_0.8_58280_None_kvanputt' |
---|
32 | time_dir5 = '20090505_151322_run_final_0.8_64477_None_kvanputt' |
---|
33 | time_dir6 = '20090505_151447_run_final_0_64477_None_kvanputt' |
---|
34 | |
---|
35 | time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6] |
---|
36 | |
---|
37 | for time_dir in time_dirs: |
---|
38 | # Local variables... |
---|
39 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
40 | raster_gbd = folder + 'raster.gdb' |
---|
41 | land_folder = scenario_dir + "ArcGIS\\data.gdb\\Land" |
---|
42 | areas = ['Hobart', 'NW', 'South'] |
---|
43 | print time_dir |
---|
44 | |
---|
45 | ## print 'Process: Create File GDB' |
---|
46 | ## gp.CreateFileGDB_management(folder, "raster") |
---|
47 | |
---|
48 | gp.Workspace = raster_gbd |
---|
49 | |
---|
50 | for area in areas: |
---|
51 | #replication dictionary |
---|
52 | replicate = (('hobart', ''), ('fitting_problem', ''), |
---|
53 | ('_', ''), ('max','_M'), ('depth','_depth'), |
---|
54 | ('speed', '_speed'), ('elevation', '_ele'), ('stage','_stage')) |
---|
55 | |
---|
56 | generate_filename = [] |
---|
57 | |
---|
58 | infile = folder + model + '_' + area + '_speed_max.asc' |
---|
59 | |
---|
60 | output_DEM = os.path.basename(infile)[:-4] |
---|
61 | for (key, rep) in replicate: |
---|
62 | output_DEM = output_DEM.replace(key,rep) |
---|
63 | output_DEM = output_DEM[:16] |
---|
64 | if output_DEM in generate_filename: |
---|
65 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
66 | sys.exit(10) |
---|
67 | generate_filename.append(output_DEM) |
---|
68 | print 'Output DEM ',output_DEM |
---|
69 | |
---|
70 | print 'Process: ASCII to Raster' |
---|
71 | gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT") |
---|
72 | |
---|
73 | print 'Process: Define Projection' |
---|
74 | gp.DefineProjection_management(output_DEM,"PROJCS['GDA_1994_MGA_Zone_55',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994'" |
---|
75 | ",SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0]" |
---|
76 | ",UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator']" |
---|
77 | ",PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0]" |
---|
78 | ",PARAMETER['Central_Meridian',147.0],PARAMETER['Scale_Factor',0.9996]" |
---|
79 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
80 | |
---|
81 | ## land = land_folder + '_' + area |
---|
82 | ## print 'Process: Extract by Mask' |
---|
83 | ## output_extract = output_DEM + '_E' |
---|
84 | ## print 'Output Extract ',output_extract |
---|
85 | ## gp.ExtractByMask_sa(output_DEM, land, output_extract) |
---|
86 | |
---|
87 | |
---|