How do I clip raster data?
This post covers how to clip out portions of raster grids (updated May 2021 for Pro).
A previous post covered how to clip vector data (feature classes and shapefiles). Another key skill is being able to clip out portions of raster grids, such as a DEM, or perhaps a TIF image. We’ve got three options really – use a raster Clip tool, use the Extract by Mask tool, or carry it out as a raster calculation. I’ll cover all three methods in this post. Let’s use the example of clipping out the Lyttelton Harbour Basin from the DEM of the South Island (this is the one I used for the post on viewsheds). Here’s a map with the DEM on it (added as J:\Data\Digital_Elevation_Models\sidem):
(Note that you can always click on the image for a bigger view of it.) As with any clip operation, a boundary is needed and more often than not, it’s a vector polygon. I created a polygon layer that defined the boundary of the area I wanted to clip.
Now I’ve got the choice of using a raster clip tool or doing a raster calculation. We’ll look at both now.
Raster Clip Tool
One quick way to see if there’s anything that might suit in ArcToolbox is to do a Search on the available tools. You could click on the Search button at the top of the Geoprocessing pane – type “clip raster” into the search window and click the Tools link to get this result:
The tool at the top looks like it might do the trick. It will ultimately, but we need to be a bit careful about how we set it up. Opening the tool brings up this window:
I’ve set my DEM as the Input Raster, LyttClip as the Output Extent and saved the output somewhere safe. I haven’t worried about the NoData Value but *importantly* note that I’ve ticked the “Use Input Features for Clipping Geometry” box. This means that my output raster will be clipped to the extent of my polygon. If I don’t tick this the output is going to be a rectangle that is the smallest one that contains the polygon (I’ll show you what I mean later…). Just to be safe I also tick the “Maintain Clipping Extent” box. Executing the tool gets me this (with the DEM turned off and a different colour ramp so you can see the result better):
If I hadn’t ticked that box, here’s what it would have looked like:
So with this output I’ve got all the data within the polygon, but I’ve also got some areas of essentially no data in the bounding rectangle (or at least data that aren’t correct.) Ticking the box makes for a cleaner output that should match other data clipped to the same boundary.
Extract by Mask Tool
Another tool we could use is in ArcToolbox > Spatial Analyst Tools > Extraction > Extract by Mask. This is a pretty straightforward tool to use and produces the same output as shown above:
We can also do our clip as a raster calculation, using the same clip polygon. It’s a bit more complicated but achieves the same end. Open up the Raster Calculator from ArcToolbox > Spatial Analyst Tools > Map Algebra > Raster Calculator.
Here I’ve double-clicked on the grid I want to clip, sidem, and set my Output Raster name. Before we do the calculation, click the Environments button. We can set a lot of tool parameters here but we’re most interested in what’s in the Raster Analysis specifically the Mask setting. Here I set it to my clip layer:
The Cell Size should automatically be picked up by the resolution of your input grid. Here’s the output:
It should be exactly the same. Two things to note, the raster calculation takes a bit longer to execute (actually a lot longer), and the Mask needs to be reset everytime you carry out a calculation – otherwise you’ll just get a copy of the whole grid.
To be honest, I’ve almost always used the raster calculation method, but having just gone through both, I think I’ll start using the Clip Raster tool instead – it’s faster and a bit less fiddly.
Now that I’ve clipped my DEM I could use it to derive slope or aspect or create a hillshade from and it will be far quicker than if I had used the whole DEM and will take up less space on my local drive.
We can use these tools on just about any grid, with the exception of multi-band grids, like JPGs or some satellite imagery. Most grids and images (e.g. TIFs) contain one “band” of information. JPGs are actually composed of three bands, one each for red, green and blue colours. Some satellite imagery has up to six or seven bands! Clipping out portions of these grids is a much more complicated process and warrants a separate post (my list of those is getting longer and longer…)