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 | # Load required toolboxes... |
---|
16 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") |
---|
17 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") |
---|
18 | gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") |
---|
19 | gp.overwriteoutput = 1 |
---|
20 | |
---|
21 | model = 'tweed' |
---|
22 | scenario_dir="\\\\nas2\\gemd\\georisk_models\\inundation\\data\\new_south_wales\\tweed_valley_flood_scenario_2009\\" |
---|
23 | output_dir = "anuga\\outputs\\" |
---|
24 | |
---|
25 | time_dir1 = '20090904_120512_run_final_0_test_mmiddelm' |
---|
26 | time_dirs = [time_dir1] |
---|
27 | |
---|
28 | for time_dir in time_dirs: |
---|
29 | # Local variables... |
---|
30 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
31 | raster_gbd = folder + 'raster.gdb' |
---|
32 | print time_dir |
---|
33 | |
---|
34 | # Make sure you comment this next two lines out if reruning this script |
---|
35 | # for a new variable ie depth and stage otherwise you will copy over the top! |
---|
36 | print 'Process: Create File GDB' |
---|
37 | gp.CreateFileGDB_management(folder, "raster") |
---|
38 | |
---|
39 | gp.Workspace = raster_gbd |
---|
40 | |
---|
41 | for area in areas: |
---|
42 | #replication dictionary |
---|
43 | replicate = (('tweed', ''),('depth','depth'), |
---|
44 | ('speed', 'speed'), ('elevation', 'elevation'), |
---|
45 | ('stage','stage')) |
---|
46 | |
---|
47 | generate_filename = [] |
---|
48 | |
---|
49 | infile = folder + '*.asc' |
---|
50 | |
---|
51 | output_DEM = os.path.basename(infile)[:-4] |
---|
52 | for (key, rep) in replicate: |
---|
53 | output_DEM = output_DEM.replace(key,rep) |
---|
54 | output_DEM = output_DEM[:14] |
---|
55 | if output_DEM in generate_filename: |
---|
56 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
57 | sys.exit(10) |
---|
58 | generate_filename.append(output_DEM) |
---|
59 | output_DEM = raster_gbd + "\\" + output_DEM |
---|
60 | print 'Output DEM ',output_DEM |
---|
61 | |
---|
62 | print 'Process: ASCII to Raster' |
---|
63 | gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT") |
---|
64 | |
---|
65 | print 'Process: Define Projection' |
---|
66 | gp.DefineProjection_management(output_DEM,"PROJCS['GDA_1994_MGA_Zone_56',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994'" |
---|
67 | ",SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0]" |
---|
68 | ",UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator']" |
---|
69 | ",PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0]" |
---|
70 | ",PARAMETER['Central_Meridian',153.0],PARAMETER['Scale_Factor',0.9996]" |
---|
71 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
72 | |
---|
73 | |
---|