source: anuga_work/production/gold_coast_2009/Arc_asc2raster_GDA94z56.py @ 7364

Last change on this file since 7364 was 7364, checked in by Leharne, 15 years ago
File size: 4.2 KB
Line 
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
10import sys, string, os, arcgisscripting, glob, os.path
11
12# Create the Geoprocessor object
13gp = arcgisscripting.create()
14
15# Check out any necessary licenses
16gp.CheckOutExtension("spatial")
17
18# Load required toolboxes...
19gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")
20gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")
21gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
22gp.overwriteoutput = 1
23
24scenario_dir="\\\\nas2\\gemd\\georisk_models\\inundation\\data\\queensland\\gold_coast_tsunami_scenario_2009\\"
25output_dir = "anuga\\outputs\\"
26
27time_dir1 = '20090508_150215_run_final_0_51469_lfountai'
28time_dir2 = '20090511_165539_run_final_0_50863_lfountai'
29time_dir3 = '20090511_161526_run_final_1.1_51469_kvanputt'
30time_dir4 = '20090518_154710_run_final_0_50994_lfountai'
31time_dir5 = '20090519_160510_run_final_1.1_50994_lfountai'
32time_dir6 = '20090521_220101_run_final_1.1_50863_kvanputt'
33time_dir7 = '20090522_164526_run_final_0_51392_lfountai'
34time_dir8 = '20090522_164640_run_final_1.1_51392_lfountai'
35time_dir9 = '20090522_164948_run_final_0_51423_lfountai'
36time_dir10 = '20090522_165600_run_final_1.1_51423_lfountai'
37
38time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5,
39             time_dir6, time_dir7, time_dir8, time_dir9, time_dir10]
40
41for time_dir in time_dirs:
42
43    # Local variables...
44    folder =  scenario_dir + output_dir + time_dir + '\\'
45    raster_gbd = folder + 'raster.gdb'
46    #contour = raster_gbd + '\\contour_dep'
47    land = scenario_dir + "ArcGIS\\gold_coast.gdb\\Land_initial_conditions"
48##    ocean = scenario_dir + "map_work\\Perth.gdb\\Outlines\\initial_condition_ocean"
49   
50    print 'Process: Create File GDB'
51    gp.CreateFileGDB_management(folder, "raster")
52
53    gp.Workspace = raster_gbd
54
55    print gp.Workspace
56   
57    #replication dictionary
58    replicate = (('gold_coast', ''), ('_time_29220_0', 'b'), ('_time_58440_0', 'c'),
59                 ('_time_28860_0', 'b'), ('_time_57720_0', 'c'),
60                 ('_', ''), ('max','M_'), ('depth','_dep_'),
61                 ('speed', '_spe_'), ('elevation', '_ele_'), ('stage','_stage'))
62
63    generate_filename = []
64    input_ascii = glob.glob(folder + '*_max.asc')
65    print time_dir
66
67    for infile in input_ascii:
68        output_DEM = os.path.basename(infile)[:-4]
69        for (key, rep) in replicate:
70            output_DEM = output_DEM.replace(key,rep)
71        output_DEM = output_DEM[:10]
72        if output_DEM in generate_filename:
73            print 'Output_DEM filename (%s) already in use' % output_DEM
74            sys.exit(10)
75        generate_filename.append(output_DEM)
76        print 'Output DEM ',output_DEM
77       
78        print 'Process: ASCII to Raster'
79        gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT")
80
81        print 'Process: Define Projection' 
82        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]]"
83                                                   ",PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',153.0],PARAMETER['Scale_Factor',0.9996]"
84                                                   ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]")
85
86
87   
88        output_extract = output_DEM + 'E'
89        print 'Output Extract ',output_extract
90   
91        print 'Process: Extract by Mask'
92        gp.ExtractByMask_sa(output_DEM, land, output_extract)
93
94       
Note: See TracBrowser for help on using the repository browser.