ArcEngine查询栅格像元属性值

  前期开发了一个三维交互查询要素属性值的功能,用到了FeatureLayer实现的IIdentify2接口。如果想实现在SceneControl中查询栅格像元属性值应该怎么做?

  首先查询OMD,想找到IIdentify2类似的接口。而IRasterLayer并没有直接实现IIdentify2接口。倒是其父类DisplayLayer实现了IIdentify接口。IIdentify接口只有一个Identify方法:帮助中其描述如下:

When the IIdentify interface is on a map layer, the Identify method returns an array of FeatureIdentifyObject objects.

On a FeatureIdentifyObject, you can do a QI to the IIdentifyObj interface to get more information about the identified feature. The IIdentifyObj interface returns the window handle, layer, and name of the feature; it has methods to flash the feature in the display and to display a context menu at the Identify location.

This method performs an identify operation with the provided geometry.  When identifying layers, typically a small envelope is passed in rather than a point to account for differences in the precision of the display and the feature geometry.

   感觉很奇怪,父类Identify方法怎么返回一个 FeatureIdentifyObject的Array数组?于是通过IIdentifyObj找到了RasterIdentifyObj对象。栅格图层返回的应该是RasterIdentifyObj数组,这样把Array对象中的要素做一下类型转换就可以获得查询结果了。我写了代码却出问题,原因有两方面,一是过滤栅格图层出错,另外是栅格调用Identify方法时传入的是一个点,而不应该是一个缓冲圆。百度中输入RasterIdentifyObj找到如下参考程序http://www.cnblogs.com/zany-hui/articles/1527563.html。测试没有问题,和我想的一致!

  看来帮助中的描述是有问题的,要素图层Identify返回FeatureIdentifyObject数组,而栅格图层返回的是RasterIdentifyObj数组。

利用IRaster.Read接口可以读取每个PixelBlock的值,输入的参数是行和列,而不是地图坐标
利用IIdentify接口可以读取指定坐标的PixelBlock的值,代码如下
IIdentify identify = (IIdentify)rasterlayer;//rasterLayer是打开的栅格图层
if(identify=null)
return;
IPoint point = new PointClass();
point.PutCoords(longitude, latitude);
IArray array=identify.Identify(point);
if (array != null)
   {
     int arraycount = array.Count;
     for (int i = 0; i < arraycount; i++)
      {
       IRasterIdentifyObj rasterIdentifyobj = (IRasterIdentifyObj)array.get_Element(i);
       if (rasterIdentifyobj !=null&&rasterIdentifyobj.MapTip !="")
       {
        MessageBox("Value:"+rasterIdentifyobj.MapTip)
        }
     } 
}

ArcGIS 的架构设计的真的很棒!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值