I have a raster file representing a large area and a shapefile of 30 polygons representing watersheds. I would like to clip the raster with the shapefile to create 30 rasters representing each watershed? I would like to automate the process as I will be repeating it for another 10 raster files representing large areas.

I'm using ArcGIS 10.1 with an advanced arcinfo license. Can this be done without the use of python?


4 Answers 4


I was trying to figure out the same thing and made this in Model Builder.

enter image description here

I am not good with scripting at all and new to model building but this was pretty easy to make and worth the effort.

Open model builder and select INSERT > Iterators > feature selection. Use the input to be your polygon shapefile that contains the 30 different polygons; hopefully they are classified differently with an attribute like name. Select the Group by fields drop down and put the name of the attribute you want to display for each individual rasters you are going to create.

Click ok, then in the Arctoolbox go to data management > raster > raster processing > Clip and just drag that tool box into your model builder window. Double click the Clip icon and input the raster you want to use. Select your output folder, then (this is the tricky part) to ensure you get 30 individual raster images type in the name %value%.tif at the end of your path location for the output.

Then click Model > Validate entire Model, then of course run entire model. It will take a while to proccess that many rasters but will certainly save time.

Last thing to change the spatial reference system click Model > Model Properties > Check Output Coordinates > Values and browse to the one you want.

  • 2
    With this model, putting that %value%.tif will ensure you that you will only have to run the model once instead of the 10 or 30 times
    – Pete
    Mar 10, 2015 at 22:04

you can loop on each polygon and perform the clip raster or extract by mask. Here is a small sample code :

import arcpy

rasterlist = arcpy.ListRasters("your_workspace")
for raster in rasterlist:
    for i in range(30):
        arcpy.MakeFeatureLayer_management("your_shapefile", "layer" + str(i), ' "FID" = ' + str(i)) #create a layer with only polygon i
        arcpy.Clip_management(raster, "#", raster[:-4] + "clip" + str(i) +" .tif","layer" + str(i), "0", "ClippingGeometry") #clip based on layer, clipping geometry will use the polygon extent only

note that you may want to use the snap raster environment to make sure that you are ligned with your original image.

  • There is no alternative with python?
    – JC11
    Jan 31, 2014 at 14:43
  • you can (I see Jens answered with model builder), but using several iterators in the same loop brings up a very complex handling of output file names. This is much easier with Python.
    – radouxju
    Jan 31, 2014 at 15:06
  • I have never used python yet, but after researching in more detail it will be the simplest way to automate this process.
    – JC11
    Jan 31, 2014 at 16:26

If you don’t want to use Python you can use Model Builder. Model Builder has several iterator tools.

Use Iterate Feature Selection to iterate over features in a feature class (your watersheds). Then use Clip Tool.

You have to run this model 10 times (one for each raster).

Here are some examples of using serveral iterate tools.


Another way to do it without Python or Modelbuilder is to use the raster clip tool in Batch Processing mode, there's a short walkthrough of the process in this old answer of mine.

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.