4

I have built a model to interpolate air pollution from 40 recording stations using IDW.

The results are then exported to an average for census divisions.

I need to repeat this process hundreds of times for every month for 15 years for five different types of air pollution.

I have all of the data by year as a new field in the recording stations' file.

Table:

Recording_Station 03jan 03feb 03mar 03apr 03may 03jun 03jul ....
1                  26.5 27.5  22.2  32.3  34.5  45.4  55.4
2                  19.1 12.2  45.3  33.3  36.6  55.4  65.5
3                  11.1 15.6  44.4  34.4  66.6  55.4  44.6

etc.

How can I re-run the model for every field without manually changing them each time?

3
  • This makes me wonder if you are able to somehow involve an UpdateCursor or something else that would let you iterate through and update rows. If you naming is similar, you might even be able to create a collection of the column names that the model/script could check before running your model on the field. If that makes any sense?
    – Branco
    Commented Sep 24, 2014 at 19:10
  • Not clear on what you are wanting to iterate; the IDW for each combination of month/year and air pollution?
    – Mox
    Commented Mar 5, 2018 at 20:03
  • Seriously consider using either Python or R for this task. You might also explore ArcGIS pro's 'tasks'
    – Mox
    Commented Mar 5, 2018 at 20:15

4 Answers 4

7

There is not an Iterate Fields tool in ModelBuilder.

I can think of two possible workarounds:

  1. Modify the model to run as a Python script. Define a list of the fields you want to use, and define a loop to go through each one and execute the IDW/export functions.

    I would go with this one personally, but it would be (much) easier with some Python knowledge.

    An example of iterating through the fields list:

    fields = ['03jan', '03feb', '03mar'] # etc.
    for field in fields:
        # your existing IDW Python code here
        # replace any instances of specific field name e.g. "03jan"
        # with the variable *field*
    

    Once you're satisfied that works, you can automatically generate a list of all fields in a feature class using the arcpy ListFields function. Make sure that you're not including Recording_Station in the fields you iterate over (which would cause weird results, and potentially crashing):

    fields = ListFields(yourFeatureClass)
    fields.remove('Recording_Station') # repeat for any other fields you don't need
    for field in fields:
        # your existing IDE Python code here [etc.]
    
  2. Set the field name as a model parameter within your ModelBuilder. Use batch processing to execute the tool hundreds of times automatically.

    This is more tedious, since you will have to manually enter (hundreds of times...!) the field names in the batch parameters, but it does allow you to run the analysis multiple times without significantly altering the model or needing to know any Python.

8
  • Ok, I have used python, but am not sure exactly how to define a list of fields I would want to use and create a loop. Do you have an example of this code?
    – user10720
    Commented Oct 1, 2014 at 18:15
  • I've added some more detail to the Python option which I hope answers that (it is untested at the moment, so please let me know any typos!)
    – Erica
    Commented Oct 1, 2014 at 18:32
  • Awesome thanks, where do I input the loop within the IDW coding?
    – user10720
    Commented Oct 1, 2014 at 18:47
  • The existing IDW coding should be inside the loop. That way your full original model will run through once for fields[0], once for fields[1], once for fields[2], etc.
    – Erica
    Commented Oct 1, 2014 at 18:54
  • Ok, but is the actual coding for the loop? I apologize, but haven't used loop coding before.
    – user10720
    Commented Oct 2, 2014 at 13:55
1

Seems like you need to nest iterators; this can only be done by placing one model within another. It is kind of pain to do, but can be done. Your inner model will run the IDW and summarize. Your outer model will feed which columns to base the IDW on. The outer model will do so by selecting column names from a list you will create, and then iterating over that list. You create the list by opening the dbf of the shapefile, copying the column labels from it, copy-paste (transpose) into Excel. Then, use 'eliminate duplicates' in Excel to make sure the names are all unique. Then save that excel as a CSV. Add that CSV to the out model. Add an iterator-(iterate by list). Call the output of that list 'fieldname' or the like.

-1

Maybe try to iterate through all the fields using the "Iterate Field" tool in Model Builder.

It will do all the fields in a feature clase.

Screenshot of the tool

7
  • How can i iterate all the columns, I see how it does it by rows, but I need it to do it by columns. Is this possible?
    – user10720
    Commented Oct 1, 2014 at 15:34
  • in the iterate fields just select the column you desire. Commented Oct 1, 2014 at 15:52
  • I need to iterate 300+ columns and it will only let me select one
    – user10720
    Commented Oct 1, 2014 at 16:01
  • Use the one called iterate row selection. Commented Oct 1, 2014 at 16:12
  • Then how do i link this to the idw, it only lets you select one z value field
    – user10720
    Commented Oct 1, 2014 at 16:58
-1

You could explore using the batch processing function on the model. Right click (see image below) the model in your toolbox and select 'Batch'. From there you can add multiple instances and each will run through the model. Unfortunately, I am not aware of any way to easily enter the content into 'Add Row'. Thus, you would be required to enter the hundreds of records for each month.

Right-Clicking model for Batch Processing

1
  • It won't let me batch, it states I have no parameters.
    – user10720
    Commented Sep 24, 2014 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.