Areal precipitation using IDW

3602
6
09-08-2013 11:03 PM
PV1
by
New Contributor
I have got the following problem. I have a catchment and several gauging stations measuring daily precipitation amounts. I would like to interpolate the precipitation amounts from these stations (points) to the whole catchment. In the next step I would like to calculate average precipitation value for the catchment. I can do it for one day (1 value for each station).
The problem is that I have 30 years of daily precipitation measurements in each station and so I need to do this process thousands of times. I have created a simple model in model builder which could do this process once, but I am not able to force it to do it repeatedly.

I need help how to automate this process.

Thanks
0 Kudos
6 Replies
PV1
by
New Contributor
I have got the following problem. I have a catchment and several gauging stations measuring daily precipitation amounts. I would like to interpolate the precipitation amounts from these stations (points) to the whole catchment. In the next step I would like to calculate average precipitation value for the catchment. I can do it for one day (1 value for each station).
The problem is that I have 30 years of daily precipitation measurements in each station and so I need to do this process thousands of times. I have created a simple model in model builder which could do this process once, but I am not able to force it to do it repeatedly.

I need help how to automate this process.

Thanks
0 Kudos
CPoynter
Occasional Contributor III
You will need to create a loop or iteration process to go through each or of your daily records. There are iteration tools in ModelBuilder or maybe export to python and code the iteration/loop process.

Regards,

Craig
0 Kudos
KundanDhakal
New Contributor
You will need to create a loop or iteration process to go through each or of your daily records. There are iteration tools in ModelBuilder or maybe export to python and code the iteration/loop process.

Regards,

Craig


Any example Craig that you would like to provide here?

I am also stuck in same condition. Iteration in model builder does not clearly mention using fields within the same shapefile/ table (each field is a measurement for a day in my case). I think examples are not clear too. If I need to use IDW and iterate across multiple fields how would I set up the model builder? Attached is the screenshot of the attribute table of the shapefile I plant to iterate.


[ATTACH=CONFIG]27643[/ATTACH]
0 Kudos
CPoynter
Occasional Contributor III
The critical part you need to manipulate is the field names. Access to these can be achieved using:

import arcpy
tbl= arcpy.ListFields(r'D:\Temp\Test.mdb\Test')
for fld_names in tbl:
     print fld_names.name


or

import arcpy
tbl = r'D:\Temp\Test.mdb\Test'
fld_names = [f.name for f in arcpy.ListFields(tbl)]
print fld_names


Second method many by more ideal for iterating in a script, as field names are stored in a python list/table.

Regards,

Craig
0 Kudos
KundanDhakal
New Contributor
Thanks Craig for your quick response. I figured out that I need to use ListField. I am struggling figuring out the correct syntax. I found a python script to iterate IDW on ESRI Forum but that script was written for ArcGIS 9.3. I've recently upgraded to 10.2 and I think the scripts are now not compatible.

I would be really grateful if you could provide further help.

--kundan


The critical part you need to manipulate is the field names. Access to these can be achieved using:

import arcpy
tbl= arcpy.ListFields(r'D:\Temp\Test.mdb\Test')
for fld_names in tbl:
     print fld_names.name


or

import arcpy
tbl = r'D:\Temp\Test.mdb\Test'
fld_names = [f.name for f in arcpy.ListFields(tbl)]
print fld_names


Second method many by more ideal for iterating in a script, as field names are stored in a python list/table.

Regards,

Craig
0 Kudos
CPoynter
Occasional Contributor III
Without testing it myself, try:

import arcpy
from arcpy import env
from arcpy.sa import *

arcpy.CheckOutExtension("Spatial")

env.workspace = 
srcFC =
cellSize =
power =
searchRadius = 

tbl= arcpy.ListFields(srcFC, 'r*')
for zField in tbl:
    print 'Processing: ' + zField

    outIDW = Idw(srcFC, zField, cellSize, power, searchRadius)
    outIDW.save(env.workspace + '\\' + zField + '_IDW')

del srcFC, cellSize, power, searchRadius, tbl, zField


You will need to set your input workspace, source featureclass, cellsize, power, radius.

You will need to have a look at the 10.2 Help reference to IDW, so you can identify which Radius method you wish to utilise.

What I have given here is a basis for development, which needs to be polished and finished to run for your application.

If it doesn't run in IDLE, run from within Python GUI in ArcGIS or ArcCatalog.

Regards,

Craig
0 Kudos