I have the following problem:
I need to calculate an average precipitation amount on a catchment using an IDW interpolation. The interpolation is performed in a loop since each precipitation station contains several years of daily measurements (10000 and more interpolations). I have managed to solve this problem by overwriting precipitation value in attribute table of the station shapefile using
The problem is that some of the stations have missing values. In this case I would like to interpolate only those stations with measurements and thus I need to somehow exclude stations with missing values from interpolation. This is my code:
import arcpy from arcpy import env from arcpy.sa import * # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Set environment settings env.workspace = r"C:/Users/peter.valent/Documents/ArcGIS/Data/Vah po LM/Test" # Set local variables inPointFeatures = r"zrazkomerne_stanice_buffer_0km.shp" zField = r"P" cellSize = 100 power = 2 searchRadius = RadiusVariable(10, 150000) extent=r"polygon_okolo_povodia.shp" mask=r"Vah_po_LM.shp" prec_table=r"tabulka.gdb\bez_udajov2" rows = arcpy.SearchCursor(prec_table) # Get names get names of all fields in prec_table field_names =  sFields=arcpy.ListFields(prec_table) for field in sFields: field_names.append(field.name) field_count=len(field_names) field_names=field_names[2:field_count] station_count=field_count-2 # Main # Get precipitation amounts for one day prec_list=range(station_count) day_count=int(arcpy.GetCount_management(prec_table).getOutput(0)) meanP=range(day_count+10) j=0 for row in rows: for i in range(0,station_count): prec_list[i]=row.getValue(field_names[i]) idx=0 uptShape=arcpy.UpdateCursor(inPointFeatures) for station in uptShape: station.P=prec_list[idx] uptShape.updateRow(station) idx=idx+1 del station del uptShape outIDW = Idw(inPointFeatures, zField, cellSize, power, searchRadius) outIDWMask=ExtractByMask(outIDW, mask) meanPrec=arcpy.GetRasterProperties_management(outIDWMask, "MEAN") meanP[j] = meanPrec.getOutput(0) print meanP[j] j=j+1
- How do I exclude some stations from interpolation?
- Is there a way how to write nodata to the attribute table?