详细介绍C# 利用IRawPixels接口遍历栅格数据的代码实例


本文摘自PHP中文网,作者黄舟,侵删。

本文主要介绍了利用IRawPixels接口遍历栅格数据。具有很好的参考价值,下面跟着小编一起来看下吧

AO的版本为10.2,开发的语言是C#。栅格数据来源IRasterDataset接口。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

IRasterBandCollection pRasterBandCollection = pRasterDataset as IRasterBandCollection;

IRasterBand pRasterBand = pRasterBandCollection.Item(0);

 IRaster pRaster = (pRasterDataset as IRasterDataset2).CreateFullRaster();

IRawPixels pRawPixels = pRasterBand as IRawPixels;

IRasterProps pRasterProps = pRasterBand as IRasterProps;

int dHeight = pRasterProps.Height;

int dWidth = pRasterProps.Width;

IPnt pntSize = new PntClass();

pntSize.SetCoords(dHeight, dWidth);

IPnt pPixelBlockOrigin = new PntClass();

pPixelBlockOrigin.SetCoords(0, 0);

IPixelBlock pixelBlock = pRaster.CreatePixelBlock(pntSize);

pRawPixels.Read(pPixelBlockOrigin, pixelBlock);

System.Array arr = (System.Array)(pixelBlock as IPixelBlock3).get_PixelData(0);

for (int i = 0; i < dHeight;i++ )

{

 for (int j = 0; j < dWidth; j++)

 {

   float number = 0;

   float.TryParse(arr.GetValue(i,j).ToString(),out number);    

  }

}

以上就是详细介绍C# 利用IRawPixels接口遍历栅格数据的代码实例的详细内容!

相关阅读 >>

C#基础入门之算法-交换的代码示例

C#中如何实现两个richtextbox控件滚动条同步滚动的方法详解

C#网络编程的图文代码详解

C#捕获windows关机事件,在系统关机前做一些自己想做的事的示例代码

C#与.net框架之间的关系是什么?C#程序的开发工具

.net的优点

C#二进制字节数组操作函数 截取字节数组subbyte的示例代码

C#中序列化实现深拷贝和datagridview初始化刷新的方法介绍

C# 日志记录类创建的源码分享

C#中guid生成格式的四种方法的示例代码分享

更多相关阅读请进入《C#》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...