Clip raster to polygon

This tool can be used to clip one or more rasters to the extent of a vector polygon (shapefile). The user must specify the names of the input raster files and the input clip file. The input clip file must be a shapefile of a Polygon base shape type. The clip file may contain multiple polygon features. Only the exterior hull of polygons will be used for clipping, i.e. polygon holes are ignored. Raster grid cells that are not within a polygon in the clip file will be assigned the NoData value in the output file. Output files have the same name as their input raster files but have a '_clipped' suffix appended. The grid resolution of output images are the same as their corresponding input rasters. If the 'Maintain input raster dimensions' option is selected, output images will also have the same number of rows and columns and geographic extent as their corresponding input rasters. If this option is not selected, the tool will crop the output raster to fit the clip polygon(s).

Clip polygons can be created using on-screen digitizing to identify an area of interest on the base raster.

See Also:

Scripting:

The following is an example of a Python script using this tool:

wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.dep" + ";" + wd + "input2.dep" + ";" + wd + "input3.dep"
clipFile = wd + "polygon.shp"
maintainDimensions = "false"
args = [inputFiles, clipFile, maintainDimensions]
pluginHost.runPlugin("ClipRasterToPolygon", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.dep" + ";" + wd + "input2.dep" + ";" + wd + "input3.dep"
def clipFile = wd + "polygon.shp"
def maintainDimensions = "true"
String[] args = [inputFiles, clipFile, maintainDimensions]
pluginHost.runPlugin("ClipRasterToPolygon", args, false)

Credits: