作者:Flyingis

    多边形裁剪影像文件最简单的情况,是使用矩形进行裁剪,在ArcEngine中ITransformationOp.Clip方法可以直接完成。

    C#

public IGeoDataset Clip (IGeoDataset GeoDataset, IEnvelope Rectangle);


    Java

public IGeoDataset clip(IGeoDataset geoDataset, IEnvelope rectangle);

    ArcObject代码示例,同样可以应用到ArcEngine:
' Create the RasterTransformationOp object
Dim pTransformationOp As ITransformationOp
Set pTransformationOp = New RasterTransformationOp

' Get raster
Dim pRas01 As IRaster
Set pRas01 = getRasterFromDiskFunction("c:datamyRaster")

' Declare an envelope object
Dim pEnvelope As IEnvelope

' Create an envelope
Set pEnvelope = New Envelope
pEnvelope.PutCoords 
1133

' Declare the output raster object
Dim pGeoDS As IGeoDataset

' Calls the method
Set pGeoDS = pTransformationOp.Clip(pRas01, pEnvelope)

    如果使用ArcEngine92,可以用Geoprocessing来处理,利用Data Management Tools-->Raster-->Clip工具来完成,python脚本参考如下代码:
# Create the geoprocessing object
import arcgisscripting
gp 
= arcgisscripting.create()

gp.workspace 
= "c:/seattle_data"
gp.Clip_management(
"seattle1.tif""549790.051000 5272863.993000 549870.051000 5273000.993000","seattle_clip.img"#)

    以上是最简单的情况,更多的,我们需要用不规则多边形polygon来进行裁剪,这时就要用到ExtractByPolygon Class,看看C#对ExtractByPolygon的属性的描述


    最基本的,写好in_raster、out_raster和polygon属性即可。