You are on page 1of 2

#------------------------------------------------------------------------------# Name: CreateGeoStatLyr_Export2pts.py # Purpose: This code uses a geostatistical layer, # "EmpiricalBayesianKriging.

xml", as a template # for creating new geostatistical layers. # Next, this code uses geostatistical analyst to convert the # geostat layer, with predicted z-values calculated # from existing z-values, to a point feature class(fc). # After that the point fc is projected to # WGS 198 UTM Zone 46N coordinate system. Next the point fc # is interpolated with kriging methodology using # the "Predicted" z-value field. Finally, the interpolated # grids are then extracted by a mask, # the country boundary, and stored in a gdb: #"C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\GeoStatAnalyst\ga_mask.gdb". #*** Use the grids in the gdb path above for the next step which: # 1. creates a flood frequency map (based on predicted z-values) between 2003-20 12 period # 2. creates an avg. flood depth map (based on predicted z-values) between 20032012 period # # Author: mbs7038 # # Created: 28/03/2014 # Copyright: (c) mbs7038 2014 # Licence: <your licence> #------------------------------------------------------------------------------import arcpy from arcpy import env from arcpy.sa import* from arcpy.ga import* # define workspace arcpy.env.workspace = "H:\Thesis\FloodData\Remove_Gauge_Outliers\Removed_Outlier s_GreaterThan_80m.gdb" # enable overwriting arcpy.env.overwriteOutput=True # define environmental mask bounds="C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\LS_Raster2P olygon_Work\Bangla.gdb\Bangla_Bounds_WGS84_EDIT_FINAL_prj" # define environmental output coordinates: WGS 1984 UTM Zone 46N arcpy.env.outputCoordianteSystem=32646 # setup output point fc path ptpath="C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\GeoStatAnalyst\ga_pt_fc s.gdb" prjpath="C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\GeoStatAnalyst\ga_pt_f cs_prj.gdb" krigpath="C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\GeoStatAnalyst\ga_kri g.gdb" maskpath="C:\Users\mbs7038\Documents\Remove_Gauge_Outliers\GeoStatAnalyst\ga_mas k.gdb" # Check out the ArcGIS Geostatistical Analyst extension license

arcpy.CheckOutExtension("GeoStats") # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # define xml model to base geostat layer on modelxml=("C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_F or_AccuracyAssessment\S_Gauges\EmpiricalBayesianKriging.xml") print 'listing feature classes' fcs=arcpy.ListFeatureClasses("*") for fc in fcs: print fc try: print 'listing fields' fields = arcpy.ListFields(fc,"Wlevel") for field in fields: print ("{0} is a type of {1} with a length of {2}".format... (field.name,field.type, field.length)) gaZ="Wlevel" krigZ="Predicted" outpts=ptpath + "/" + fc + "_GA_pt" outprj=prjpath + "/" + fc + "_GA_ptprj" outkrig=krigpath + "/" + fc + "_GA_prjkrig" outmask= maskpath+ "/" + fc + "_GA_mask" print'creating geostatistical layer' infc=fc + " Wlevel" arcpy.GACreateGeostatisticalLayer_ga(modelxml,infc,'outlyr') print 'converting GA layer to points' arcpy.GALayerToPoints_ga('outlyr',fc,gaZ,outpts) print 're-projecting to UTM coordinate system' arcpy.Project_management(outpts,outprj,32646) # interpolate "Predicted" z-values from Geostatistical Analyst output # cell size is 90m x 90m for projected coordinate system # cell size is 0.0008333333 x 0.0008333333 for geographic coordinate sys print ('kriging {0}'.format(fc)) Krig=arcpy.sa.Kriging(outprj,krigZ,KrigingModelOrdinary... ("Spherical",90),90) Krig.save(outkrig) print ('extracting {0} by {1}').format(fc,"Country Boundary") Mask=arcpy.sa.ExtractByMask(outkrig,bounds) Mask.save(outmask) except: print arcpy.GetMessages() print 'script complete'

You might also like