5

I have a large number of raster images. What I'd like to do is to compute statistics on different sections of these raster files using a polygon. I think everyone is suggesting Zonal statistics. However, I'd like to iterate through all the raster datasets and then store their statistics in a single table. Zonal statistics does this for one raster and then overwrite it next time. I used the %Name% inline variable as for my table name, but that just creates lots of tables.

How can I iterate through all this raster datasets and create only one table?

6
  • This would be an easy task in python. Are you familiar at all with python scripting?
    – Radar
    Nov 29, 2013 at 21:45
  • Unfortunately not a whole lot. I can run and modify scripts but not very familiar with functions and commands. However, am willing to try.
    – FlyingMGET
    Nov 30, 2013 at 0:10
  • I am trying to do the same task but I am using .img raster so the calculate field is not working since the add field renames the .img and drops the (.) so the field name is not found in table, how can I handle that ?
    – user25897
    Jan 17, 2014 at 1:27
  • Seems like you are trying to add field to the raster (.img)???? Have you tried one of the models below??
    – FlyingMGET
    Jan 18, 2014 at 17:38
  • How do I create a target table? I tried to run model but shows error about target dataset. Jan 24, 2019 at 15:20

3 Answers 3

3

If you want to do this entirely within ModelBuilder you would create a model that iterates over your rasters, feed into a zonal stats tool and the output of that feed into a collects tool exposed as a parameter as shown below.

Sub model

This becomes a sub-model in a model that takes the collected tables and appends them into a single table as show below.

Master model

4
  • 1
    Thanks @Hornbydd. I implemented your idea and actually combined the two models, and I got it to work fine. One should keep in mind that the receiving table must have the exact same attribute and column names as the iterative tables so each new table can be appended.
    – FlyingMGET
    Nov 30, 2013 at 17:12
  • Is there a way to retrieve input raster file names and save them in the final table? This is a big help since I cant exactly say which value in the table goes to which raster.
    – FlyingMGET
    Dec 1, 2013 at 6:48
  • 2
    Yeah, before you send your table to the collects tool put in an add field then calculate tool where the expression would be %Name%.
    – Hornbydd
    Dec 2, 2013 at 10:05
  • I tried to add field and calculate to add a field of the original file names, but I have problems making it work. Can you maybe post a screen shot of that part?
    – dtanon
    Dec 5, 2016 at 15:13
3

My previous answer had some issues as @Hornbydd mentioned! So here is the one that worked. I could even ran it without having the "Collect tools" inside the model and just used the "Append" tool. enter image description here

1
  • 1
    Are you able to keep the origonal file names in this set up?
    – dtanon
    Dec 2, 2016 at 14:04
2

I know this is an old post, but I came across it recently looking for similar answers. I failed at implementing these methods, but I found a different way of approaching it with ModelBuilder that was successful in appending fields named the same as the rasters. Basically by iterating the rasters to add fields, then joining and copying across the relevant data. My model is below:

enter image description here

This still creates a long list of tables, but if they are stored in a 'disposable' geodatabase they can be deleted at the end as all the values are attached to the point file's attribute table.

enter image description here

Your Answer

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

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