Flyingis

Talking and thinking freely !
Flying in the world of GIS !
随笔 - 156, 文章 - 16, 评论 - 589, 引用 - 0
数据加载中……

用多边形裁剪影像文件

    作者: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属性即可。

posted on 2007-04-12 11:23 Flyingis 阅读(4834) 评论(1)  编辑  收藏 所属分类: ArcEngine

评论

# re: 用多边形裁剪影像文件[未登录]  回复  更多评论   

博主,你好!我最近写一个用多边形裁剪影像数据的程序,将多边形选定范围的影像图输出,另存为单独的栅格文件,我用你上面的方法试了下,没有成功,楼主能把完整的代码发给我一份吗?或者给我指点一下也可以,先谢谢楼主拉~~
我qq:306407957
E-mail:wd0360115@126.com
2008-05-24 22:12 | SunShine

只有注册用户登录后才能发表评论。


网站导航: