I have a very large raster for which I am trying to compute zonal means using a shapefile that covers the same extent but has hundreds of thousands of individual polygons as zones. Trying to just use the large shapefile as the input feature zone and the raster as the value raster doesn't seem to work.

What I have done is split up the large shapefile into ~50 shapefiles containing a more manageable number of individual polygons in each. I am now trying to use ModelBuilder to iterate through those ~50 shapefiles and compute the zonal mean using their individual polygons and the large value raster.

What I am having trouble with is changing the processing extent to match that of the zone shapefile for each iteration. This seems necessary for this workflow to complete successfully (It worked for me when I tried it manually on one of the shapefiles, outside of ModelBuilder) - if I leave the extent as default, or set it to that of the large raster, the tool freezes or crashes.

It seems like I should change the processing extent in ModelBuilder to "Same as variable 'input shapefile'".

Will this change the extent with each iteration?

The few times I have tried this it crashes ArcMap and I get the message:

ArcGIS Desktop has encountered a serious application error and is unable to continue.

  • You are on correct path. The tool - MB is wrong though. This gis.stackexchange.com/questions/112946/… will handle any number of polygons
    – FelixIP
    Commented Dec 1, 2015 at 19:09
  • just a question : is your scratch workspace located on a disk with enough space ?
    – radouxju
    Commented Dec 1, 2015 at 20:25
  • @FelixP: My raster has 43446 rows and 71764 columns, I think it might be a little big to convert to points. I am writing the output table (I'm using Zonal Statistics as Table, forgot to mention in the original post) to an external drive with ~145 GB of free space. I don't think a table would take up that much space?
    – David
    Commented Dec 1, 2015 at 21:01
  • @David there are 2 solutions, you've picked a wrong one, the one i meant is on the top. It is overkill, because it handles the issue of overlapping polygons for zonal statistics. Nevertheless it will work in your case. It is very close to Hornbydd solution anyway. I just don't trust mbuilder
    – FelixIP
    Commented Dec 2, 2015 at 4:32

1 Answer 1


I've not tested this as the machine I am using does not have a Spatial Analyst extension.

You don't show what you have actually done so I am assuming you have a simple model as such:


Note the output of the iterator is a parameter to the zonal stats tool AND an environment setting. I used the connect wand to connect it as an Environments > Extent.

  • that is exactly what my model looks like and thanks for the tip! I didn't realize that you could use the connect want to set extents, that seems like it is exactly what I needed to do. I was also able to accomplish what I believe is the same thing by setting the extent in the model environments to "intersection of inputs", which if I am understanding correctly should set the extent only to the area where the inputs (small shapefile and large raster) overlap, which would be the same as just the extent of the shapefile.
    – David
    Commented Dec 2, 2015 at 14:50
  • The only problem I am encountering now is that after several iterations of the model, ArcMap crashes. This happens when the extent is set to intersection of inputs in the model environments, when I try to use the mothod @Hornbydd suggested it crashes when the first iteration reaches 100%.
    – David
    Commented Dec 2, 2015 at 14:55
  • I would watch the dialog see what the featureclass is being used in the zonal stats tool when it crashes and then simply run that tool by itself (so not in modelbuilder). If it throws an error, then it would suggest something is odd about that dataset, maybe run a check geometry on it?
    – Hornbydd
    Commented Dec 2, 2015 at 17:41
  • I think the problem is actually with the masks that I am trying to use. I found out that my model works fine when I don't specify a mask, but using a mask causes problems. ArcMap even crashes when I try to load my mask rasters at their full extent, I have to be zoomed in or turn the mask layer off in order to not crash ArcMap. Not sure why this is the case.
    – David
    Commented Dec 2, 2015 at 22:15

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