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 = 0 |
---|
23 | |
---|
24 | scenario_dir = "\\\\nas2\\gemd\\georisk_models\\inundation\\data\\australia_ph2\\maningrida\\" |
---|
25 | output_dir="anuga\\outputs\\" |
---|
26 | |
---|
27 | time_dir1 = '20090415_123320_run_final_0_64970_1878_Tb__kvanputt' |
---|
28 | time_dir2 = '20090418_092859_run_final_0_71078_1878_Tb__kvanputt' |
---|
29 | time_dir3 = '20090421_012030_run_final_0_71141_1878_Tb__kvanputt' |
---|
30 | time_dir4 = '20090422_115416_run_final_0_64970_1878_Tb_internal_mhingee' |
---|
31 | |
---|
32 | ##time_dirs = [time_dir2, time_dir3, time_dir4] |
---|
33 | time_dirs = [time_dir4] |
---|
34 | |
---|
35 | for time_dir in time_dirs: |
---|
36 | # Local variables... |
---|
37 | folder = scenario_dir + output_dir + time_dir +'\\' |
---|
38 | raster_gbd = folder + 'raster.gdb' |
---|
39 | ## land = scenario_dir + "map_work\\Busselton.gdb\\Internal_polygons\\initial_conditions_extend_Di" |
---|
40 | ## ocean = scenario_dir + "map_work\\Busselton.gdb\\input_boundaries\\Ocean" |
---|
41 | |
---|
42 | |
---|
43 | ## print 'Process: Create File GDB' |
---|
44 | ## gp.CreateFileGDB_management(folder, "raster") |
---|
45 | |
---|
46 | gp.Workspace = raster_gbd |
---|
47 | |
---|
48 | print time_dir |
---|
49 | |
---|
50 | #replication dictionary |
---|
51 | replicate = (('maningrida', ''),('_', ''),('All',''), |
---|
52 | ('depth','_depth'),('speed', '_speed'),('max','_M'), |
---|
53 | ('elevation', '_ele_'), ('stage','_stage')) |
---|
54 | |
---|
55 | generate_filename = [] |
---|
56 | input_ascii = glob.glob(folder + '*elevation.asc') |
---|
57 | |
---|
58 | for infile in input_ascii: |
---|
59 | output_DEM = os.path.basename(infile)[:-4] |
---|
60 | for (key, rep) in replicate: |
---|
61 | output_DEM = output_DEM.replace(key,rep) |
---|
62 | output_DEM = output_DEM[:12] |
---|
63 | if output_DEM in generate_filename: |
---|
64 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
65 | sys.exit(10) |
---|
66 | generate_filename.append(output_DEM) |
---|
67 | |
---|
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['CM_133',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]" |
---|
75 | ",PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',133.0],PARAMETER['Scale_Factor',0.9996]" |
---|
76 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
77 | ## output_extract = output_DEM + '_E' |
---|
78 | ## print 'Output Extract ',output_extract |
---|
79 | ## print 'Process: Extract by Mask' |
---|
80 | ## gp.ExtractByMask_sa(output_DEM, land, output_extract) |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | |
---|