博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Arcgis中将栅格数据导出成Txt格式
阅读量:7228 次
发布时间:2019-06-29

本文共 1593 字,大约阅读时间需要 5 分钟。

IWorkspaceFactory wf = new RasterWorkspaceFactory();            IWorkspace ws = wf.OpenFromFile(path, 0);                        IRasterWorkspace rastWork = (IRasterWorkspace)ws;            IRasterDataset3 rds =(IRasterDataset3) rastWork.OpenRasterDataset(tmp+"2.img");            IRasterBandCollection rasterbands = (IRasterBandCollection)rds;                        IRaster raster = rds.CreateFullRaster(); RasterToText2(raster, path + "\\123.txt");        private void RasterToText2(IRaster raster, string txtFile)        {               var datas = RasterArray(raster);            StreamWriter sw = new StreamWriter(txtFile, false, Encoding.UTF8);            for (int i = 0; i < datas.GetLength(0); i++)            {                for (int j = 0; j < datas.GetLength(1); j++)                {                    sw.Write(datas.GetValue(i, j).ToString() + " ");                }                sw.WriteLine();            }            sw.Close();        }        public static System.Array RasterArray(IRaster raster)        {            IRasterProps props = (IRasterProps)raster;            //novalue = props.NoDataValue;            IPnt pBlockSize = new PntClass();            pBlockSize.SetCoords((double)props.Width, (double)props.Height);            IRaster2 raster2 = (IRaster2)raster;            IPixelBlock pixelBlock = raster2.CreateCursorEx(pBlockSize).PixelBlock;            pBlockSize.SetCoords(0.0, 0.0);            raster.Read(pBlockSize, pixelBlock);            IPixelBlock3 block2 = (IPixelBlock3)pixelBlock;            return (System.Array)block2.get_PixelData(0);        }

转载地址:http://ngbfm.baihongyu.com/

你可能感兴趣的文章
Zxing扫描二维码
查看>>
我的友情链接
查看>>
aspcms后台拿shell漏洞(非添加模块)及修复方法
查看>>
C语言冒泡排序法
查看>>
B2B行业门户网站群发邮件时间及发送频率
查看>>
关于虚拟机能ping通物理机,而物理机ping不通虚拟机问题解决。
查看>>
同台机器启动多个mysql
查看>>
iframe 跨域高度自适应
查看>>
struts2+hibernate3+spring3(ssh2)框架下的web应用
查看>>
Linux下的三个时间属性
查看>>
semanage
查看>>
[case分享]Exchange 2010 登陆OWA查看邮件出现Rights managem operation failed
查看>>
linux dd 读取 写入磁盘速度
查看>>
dmidecode查看linux硬件信息
查看>>
linux监控对象及重要性
查看>>
walle-web自动化部署配置
查看>>
opencv轮廓提取、轮廓识别相关要点
查看>>
BOOST.ASIO源码剖析(一)
查看>>
过滤squidlog中各个链接的大小
查看>>
我的友情链接
查看>>