Changeset 7568
- Timestamp:
- Nov 24, 2009, 4:25:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/production/new_south_wales/batemans_bay/compare_inundation_areas.py
r7565 r7568 9 9 from os.path import join 10 10 # Create the Geoprocessor object 11 gp = arcgisscripting.create( )11 gp = arcgisscripting.create(9.3) 12 12 13 13 # Check out any necessary licenses … … 37 37 ## 'Puysegur_1000yr':58226, 38 38 ## 'Puysegur_5000yr':58286, 39 ## 'Puysegur_15000yr':58272, 39 40 ## 'New_Hebrides_200yr':51077, 40 41 ## 'New_Hebrides_500yr':51378, … … 53 54 instantaneous_energy = line_split[2] 54 55 run_up_madsen = line_split[3][0:5] 55 56 event_name = False 56 57 for key, value in event_dict.iteritems(): 57 58 if value == int(event_id): 58 59 event_name = key 60 if event_name == False: 61 continue 59 62 raster_path = join(filePath,event_name,'raster.gdb') 60 63 61 64 62 65 print event_id … … 135 138 #################################################################################### 136 139 # Local variables... 137 inundation = raster_path 140 gp.workspace = raster_path 141 print raster_path 142 inundation_name = gp.ListRasters("*depth*","") 143 for raster in inundation_name: 144 print raster 145 inundation = raster_path + "\\"+ inundation_name[0] 138 146 inundation_area1 = "N:\\georisk_models\\inundation\data\\new_south_wales\\batemans_bay_tsunami_scenario_2009\\anuga\\polygons\\polygons.gdb\inundation_area1" 139 inundation_reclass = filePath+"elevation\\elevation.gdb\\elevation_"+run_up_name+"_reclass" 140 inundation_poly = filePath+"elevation\\features.gdb\\elevation_"+run_up_name+"_poly" 141 inundation_less = filePath+"elevation\\features.gdb\\elevation_"+run_up_name+"_less" 142 inundation_less_final = filePath+"elevation\\features.gdb\\elevation_less_final" 143 144 # Process: Extract elevation data by Mask... 145 print 'check if elevation already extracted' 146 if gp.Exists(elevation_extract)!=True: 147 inundation_extract = "inundation_"+run_up_name+"_extract" 148 inundation_reclass = "inundation_"+run_up_name+"_reclass" 149 inundation_poly = "inundation_"+run_up_name+"_poly" 150 inundation_less = "inundation_"+run_up_name+"_less" 151 inundation_less_final = "inundation_less_final" 152 153 # Process: Extract inundation data by Mask... 154 print 'check if inundation already extracted' 155 if gp.Exists(inundation_extract)!=True: 147 156 print 'not already extracted' 148 157 print 'extracting by mask' 149 gp.ExtractByMask_sa(elevation, inundation_area1, elevation_extract) 150 else: 151 print 'extracted elevation already exists' 152 153 # Process: Reclassify elevation data 154 print 'check if elevation already reclassified' 155 if gp.Exists(elevation_reclass)!=True: 156 print 'reclassify based on elevation height of:', run_up_height 157 reclass_level = "-200 "+run_up_height+" 1;"+run_up_height+" 300 0" 158 gp.Reclassify_sa(elevation_extract, "Value", reclass_level, elevation_reclass, "DATA") 159 else: 160 print 'elevation has previously been reclassified for this height:', run_up_height 158 gp.ExtractByMask_sa(inundation, inundation_area1, inundation_extract) 159 else: 160 print 'extracted inundation already exists' 161 162 # Process: Reclassify inundation data 163 print 'check if inundation already reclassified' 164 if gp.Exists(inundation_reclass)!=True: 165 print 'reclassify based on inundation' 166 gp.Reclassify_sa(inundation_extract, "Value", "-200 0 1;0 300 0", inundation_reclass, "DATA") 167 else: 168 print 'inundation has previously been reclassified for this height:', run_up_height 161 169 162 170 # Process: Raster to Polygon... 163 171 print 'check if already converted from raster to polyon' 164 if gp.Exists( elevation_poly)!=True:172 if gp.Exists(inundation_poly)!=True: 165 173 print 'raster to polyon' 166 gp.RasterToPolygon_conversion( elevation_reclass, elevation_poly, "NO_SIMPLIFY", "VALUE")167 else: 168 print ' elevation raster already converted to polygon'174 gp.RasterToPolygon_conversion(inundation_reclass, inundation_poly, "NO_SIMPLIFY", "VALUE") 175 else: 176 print 'inundation raster already converted to polygon' 169 177 170 178 # Process: Select... 171 179 print 'select by attribute' 172 gp.Select_analysis( elevation_poly, elevation_less, "\"GRIDCODE\" = 1")180 gp.Select_analysis(inundation_poly, inundation_less, "\"GRIDCODE\" = 1") 173 181 174 182 # Process: Create layer... 175 183 print 'creating layers' 176 184 gp.MakeFeatureLayer(batemans_bay_SMARTLINE,'smartline_layer') 177 gp.MakeFeatureLayer( elevation_less,'elevation_layer')185 gp.MakeFeatureLayer(inundation_less,'inundation_layer') 178 186 179 187 # Process: Select Layer By Location... 180 188 print 'select by location' 181 gp.SelectLayerByLocation_management(' elevation_layer', "INTERSECT", 'smartline_layer', "", "NEW_SELECTION")189 gp.SelectLayerByLocation_management('inundation_layer', "INTERSECT", 'smartline_layer', "", "NEW_SELECTION") 182 190 print 'joining' 183 gp.SpatialJoin_analysis(' elevation_layer',inundation_area1, elevation_less_final,"JOIN_ONE_TO_ONE","","","INTERSECTS")191 gp.SpatialJoin_analysis('inundation_layer',inundation_area1, inundation_less_final,"JOIN_ONE_TO_ONE","","","INTERSECTS") 184 192 185 193
Note: See TracChangeset
for help on using the changeset viewer.