4

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?

  • This would be an easy task in python. Are you familiar at all with python scripting? – Radar Nov 29 '13 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 '13 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 '14 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 '14 at 17:38
  • How do I create a target table? I tried to run model but shows error about target dataset. – Bimal Gyawali Jan 24 at 15:20
2

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

  • 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 '13 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 '13 at 6:48
  • 1
    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 '13 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 '16 at 15:13
2

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

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

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, privacy policy and cookie policy

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