How To: Clip a hole in a raster based on a shapefile
Instructions provided show how to clip a hole in a raster based on the shape of a shapefile.
Spatial Analyst is required for this procedure.
- Create a new integer field in the polygon shapefile that is used to clip the hole in the raster.
- Calculate this field = 1.
- Convert this shapefile to a raster using Spatial Analyst toolbar > Convert > Features to Raster.
- Specify the field previously created for 'Field'.
- Specify the same cell size as the underlying raster and specify an output raster.
- The polygon is rasterized, such as Poly_Raster. 'Poly_Raster' needs to be the same extent as the other raster. Go to ArcToolbox > Spatial Analyst Tools > Map Algebra > Single Output Map Algebra.
- Copy the following statement into this tool, changing the path to the raster previously created:
CON(ISNULL(C:\Data\'Poly_Raster'), 0, (C:\Data\'Poly_Raster'))
- Click 'Environments' at the bottom of this tool. Expand 'General Settings'.
- Scroll down to 'Extent' and specify this as the underlying larger raster.
- Click OK > specify an output raster > click OK to run the tool. The output raster, such as Poly_Raster_2 is the same size as the underlying raster. The extended extent of Poly_Raster_2 has pixel values of 0. Use this raster to clip the polygon shape from the original raster.
- Go to ArcToolbox > Spatial Analyst Tools > Conditional > Set Null.
- Specify 'Poly_Raster_2' for Input Conditional Raster.
- Specify the raster dataset that is clipped (original raster) for Input False Raster or Constant Value.
- Specify an output raster.
- For the expression, type 'Value = 1'.
- Click OK to run the tool. This tool returns values of the original raster where 'Poly_Raster_2' does not equal zero, and returns 'NoDATA' where it does.