[5971] | 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\\thailand\\patong_tsunami_scenario\\" |
---|
| 25 | output_dir="anuga\\outputs\\" |
---|
| 26 | |
---|
| 27 | |
---|
[6066] | 28 | time_dir1 = '20081126_141801_run_final_0.8_kvanputt' |
---|
[5971] | 29 | |
---|
| 30 | time_dirs = [time_dir1] |
---|
| 31 | |
---|
| 32 | for time_dir in time_dirs: |
---|
| 33 | |
---|
| 34 | # Local variables... |
---|
| 35 | folder = scenario_dir + output_dir + time_dir + '\\' |
---|
| 36 | raster_gbd = folder + 'raster.gdb' |
---|
| 37 | # land = scenario_dir + "map_work\\Patong.gdb\\poly_all_cut" |
---|
| 38 | |
---|
[6066] | 39 | print 'Process: Create File GDB' |
---|
| 40 | gp.CreateFileGDB_management(folder, "raster") |
---|
[5971] | 41 | |
---|
| 42 | gp.Workspace = raster_gbd |
---|
| 43 | |
---|
| 44 | #print gp.Workspace |
---|
| 45 | |
---|
| 46 | #replication dictionary |
---|
[6066] | 47 | replicate = (('patong', ''),('_', '') ,('depth','_dep_'), |
---|
| 48 | ('speed', '_spe_'), ('elevation', '_ele_'), ('stage','_sta_')) |
---|
[5971] | 49 | |
---|
| 50 | generate_filename = [] |
---|
[6066] | 51 | input_ascii = glob.glob(folder + '*.asc') |
---|
[5971] | 52 | |
---|
| 53 | for infile in input_ascii: |
---|
| 54 | output_DEM = os.path.basename(infile)[:-4] |
---|
| 55 | for (key, rep) in replicate: |
---|
| 56 | output_DEM = output_DEM.replace(key,rep) |
---|
| 57 | output_DEM = output_DEM[:10] |
---|
| 58 | if output_DEM in generate_filename: |
---|
| 59 | print 'Output_DEM filename (%s) already in use' % output_DEM |
---|
| 60 | sys.exit(10) |
---|
| 61 | generate_filename.append(output_DEM) |
---|
| 62 | print 'Output DEM ',output_DEM |
---|
| 63 | output_extract = output_DEM + 'E' |
---|
| 64 | print 'Output Extract ',output_extract |
---|
| 65 | |
---|
| 66 | print 'Process: ASCII to Raster' |
---|
| 67 | gp.ASCIIToRaster_conversion(infile, output_DEM, "FLOAT") |
---|
| 68 | |
---|
| 69 | print 'Process: Define Projection' |
---|
| 70 | gp.DefineProjection_management(output_DEM, "PROJCS['WGS_1984_UTM_Zone_47N',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984'" |
---|
| 71 | ",SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0]" |
---|
| 72 | ",UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator']" |
---|
| 73 | ",PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0]" |
---|
| 74 | ",PARAMETER['Central_Meridian',99.0],PARAMETER['Scale_Factor',0.9996]" |
---|
| 75 | ",PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]") |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | ## print 'Process: Extract by Mask' |
---|
| 80 | ## gp.ExtractByMask_sa(output_DEM, land, output_extract) |
---|
| 81 | |
---|
| 82 | |
---|