Clip

Zusammenfassung

Creates a raster object that is clipped according to the extent of an input raster dataset or the shape of an input polygon feature class.

Auswertung

Use the Clip function to extract a portion of your raster dataset according to a defined spatial extent. For example, to process a small region within a Landsat image, you can clip the raster to the region of interest.

The function creates a raster object that has been cut out from the referenced raster object.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

Syntax

Clip (in_raster, aoi)
ParameterErklärungDatentyp
in_raster

The input raster.

Raster
aoi

Defines the area of interest (AOI), or clipping extent, used to clip the raster. Supported AOI options include Raster, Extent, and Polygon geometry.

Extent
Rückgabewert
DatentypErklärung
Raster

The output clipped raster.

Codebeispiel

Clip example 1

Clips a national land cover raster dataset to the extent of a single state.

import arcpy
from arcpy.ia import *


# Set input raster
in_raster = arcpy.Raster("USA_Landcover.tif")

# Clip the raster using a feature extent
clip_raster = arcpy.ia.Clip(in_raster, aoi = "C:\Data\California_State.shp")
clip_raster.save("California_Landcover.tif")
Clip example 2

Clips a raster object using a Polygon class.

import arcpy
from arcpy.ia import *

# Set input raster
in_raster = arcpy.Raster("us_landcover.tif")

# Create a polygon geometry object using the array object
coordinates = [[-102.78838, 42.9953], [-104.0594, 43.8529], 
	[-104.0489, 45.942993], [-102.78838, 42.9953]]
array = arcpy.Array([arcpy.Point(x, y) for x, y in coordinates])
polygon_geometry=arcpy.Polygon(array, arcpy.SpatialReference(4326))

# Clip the raster using the polygon geometry
clip_raster = arcpy.ia.Clip(in_raster, aoi = polygon_geometry)
clip_raster.save("landcover_clipped_by_polygon_geometry.tif")