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 的架構設計的真的很棒!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM