zoukankan      html  css  js  c++  java
  • 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 的架构设计的真的很棒!

    文章未经说明均属原创,学习笔记可能有大段的引用,一般会注明参考文献。 欢迎大家留言交流,转载请注明出处。
  • 相关阅读:
    ie 中window.open无法带referrer
    es6 学习7 Set 和 Map 数据结构
    ES6 学习6 数组的扩展
    ES6 学习3 函数
    ES6学习之环境配置
    理解闭包
    javascript中实现继承的几种方式
    js 原型和原型链
    Vue学习之v-if与v-show的区别
    unity图集切成多张图片的方法
  • 原文地址:https://www.cnblogs.com/yhlx125/p/2999286.html
Copyright © 2011-2022 走看看