




已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
arcengine栅格数据使用总结 两个星期以来一直与栅格数据打交道,对ao的栅格部分应该有了一定的理解,下面是自己的一点体会,希望高手指教:)1、栅格数据的存储类型栅格数据一般可以存储为esri grid(由一系列文件组成),tiff格式(包括一个tif文件和一个aux文件),imagine image格式 在ae中一般调用isaveas接口来保存栅格数据2、栅格数据集和栅格编目的区别一个栅格数据集由一个或者多个波段(rasterband)的数据组成,一个波段就是一个数据矩阵。对于格网数据(dem数据)和单波段的影像数据,表现为仅仅只有一个波段数据的栅格数据集,而对于多光谱影像数据则表现为具有多个波段的栅格数据集栅格编目(rastercatalog)用于显示某个研究区域内各种相邻的栅格数据,这些相邻的栅格数据没有经过拼接处理合成一副大的影像图3、irasterworkspaceex与irasterworkspace ,irsterworkspace2的区别1).irasteworkspaceex接口主要是用来读取geodatabase中的栅格数据集和栅格编目2) . irasterworkspace ,irsterworkspace2主要是用来读取以文件格式存储在本地的栅格数据4、加载栅格数据(以存储在本地的栅格数据文件为例)1.直接用irasterlayer接口打开一个栅格文件并加载到地图控件irasterlayer rasterlayer = new rasterlayerclass();rasterlayer.createfromfilepath(filename); / filename指存本地的栅格文件路径axmapcontrol1.addlayer(rasterlayer, 0);2. 用irasterdataset接口打开一个栅格数据集iworkspacefactory workspacefactory = new rasterworkspacefactory();iworkspace workspace;workspace = workspacefactory.openfromfile(inpath, 0); /inpath栅格数据存储路径if (workspace = null)console.writeline(could not open the workspace.);return;irasterworkspace rastwork = (irasterworkspace)workspace;irasterdataset rastdataset;rastdataset= rastwork.openrasterdataset(inname);/inname栅格文件名if (rastdataset = null)console.writeline(could not open the raster dataset.);return;5、如何读取栅格数据的属性和遍历栅格数据栅格数据的属性包括栅格大小,行数,列数,投影信息,栅格范围等等,见下面代码(假设当前加载的栅格文件栅格值存储方式为:ushort类型)irasterprops rasterprops = (irasterprops)clipraster;int dheight = rasterprops.height;/当前栅格数据集的行数int dwidth = rasterprops.width; /当前栅格数据集的列数double dx = rasterprops.meancellsize().x; /栅格的宽度double dy = rasterprops.meancellsize().y; /栅格的高度ienvelope extent=rasterprops.extent; /当前栅格数据集的范围rstpixeltype pixeltype=rasterprops.pixeltype; /当前栅格像素类型ipnt pntsize = new pntclass();pntsize.setcoords(dx, dy);ipixelblock pixelblock = clipraster.createpixelblock(pntsize);ipnt pnt = new pntclass();for (int i = 0; i dheight; i+)for (int j = 0; j dwidth; j+)pnt.setcoords(i, j);clipraster.read(pnt, pixelblock);if (pixelblock != null)object obj = pixelblock.getval(0, 0, 0);messagebox.show( convert.touint32(obj).tostring();6、如何提取指定的范围的栅格数据提取指定范围内的栅格数据通常用两种方法irasterlayerexport(esricarto), iextractionop, iextractionop2 (url=esrispatialanalyst/url),irasterlayerexport接口提供的栅格数据提取功能有限,只能以矩形范围作为提取范围,而iextractionop接口提供了多边形,圆,属性,矩形等几种形式作为提取栅格数据.1).irasterlayerexport接口irasterlayerexport rlayerexport = new rasterlayerexportclass();rlayerexport.rasterlayer = rasterlayer;/ rasterlayer指当前加载的栅格图层rlayerexport.extent = clipextent;/clipextent指提取栅格数据的范围if (prospatialref != null)rlayerexport.spatialreference = prospatialref;/ prospatialref当前栅格数据的投影信息iworkspacefactory pwf = new rasterworkspacefactoryclass();tryiworkspace prasterworkspace = pwf.openfromfile(_folder, 0);/ _folder指栅格文件保存路径irasterdataset outgeodataset = rlayerexport.export(prasterworkspace, code, strrastertype);/调用isaveas接口将导出的数据集保存.catch(exception ex)throw new argumention(ex.message);2iextractionop接口(调用此接口前,应该先检查空间许可)iextractionop extraction = new rasterextractionopclass();tryigeodataset geodataset = extraction.rectangle(igeodataset)clipraster, clipextent, true);iraster raster = geodataset as iraster;if (raster != null)iworkspacefactory wf = new rasterworkspacefactoryclass();iworkspace rasterworkspace = wf.openfromfile(_folder, 0);isaveas saveas = (isaveas)raster;saveas.saveas(“result.tif”, rasterworkspace, tiff);catch (exception ex)messagebox.show(ex.message);7栅格数据重采样栅格数据的重采样主要基于三种方法:最邻近采样(nearest),双线性ilinear)和三次卷积采样(cubic)。(1).最邻近采样:它用输入栅格数据中最临近栅格值作为输出值。因此,在重采样后的输出栅格中的每个栅格值, 都是输入栅格数据中真实存在而未加任何改变的值。这种方法简单易用,计算量小,重采样的速度最快。(2).双线性采样:此重采样法取待采样点(x,y)点周围四个邻点,在y方向(或x方向)内插两次,再在x方向(或y方向)内插一次,得到(x,y)点的栅格值。(3).三次卷积采样:这是进一步提高内插精度的一种方法。它的基本思想是增加邻点来获得最佳插值函数。取待计算点周围相邻的16个点,与双线性采样类似,可先在某一方向上内插,如先在x方向上,每四个值依次内插四次,再根据四次的计算结果在y方上内插,最终得到内插结果代码示例:采用双线性采样irastergeometryproc rastergeometryproc = new rastergeometryprocclass();rastergeometryproc.resample(rstresamplingtypes.rsp_cubicconvolution, newcellsize, clipraster);tag标签: 栅格数据 arcengine标签:栅格 重分类 分类:ae二次开发 public static irasterlayer setviewshedrenderer(iraster pinraster,string sfield,string spath) irasterdescriptor prd = new rasterdescriptorclass(); prd.create(pinraster, new queryfilterclass(), sfield); ireclassop preclassop = new rasterreclassopclass(); igeodataset pgeodataset=pinraster as igeodataset; irasteranalysisenvironment penv = preclassop as irasteranalysisenvironment; iworkspacefactory pwsf=new rasterworkspacefactoryclass(); iworkspace pws = pwsf.openfromfile(spath, 0); penv.outworkspace = pws; object objsnap = null; object objextent = pgeodataset.extent; penv.setextent(esrirasterenvsettingenum.esrirasterenvvalue, ref objextent, ref objsnap); penv.outspatialreference = pgeodataset.spatialreference; irasterlayer prlayer = new rasterlayerclass(); irasterbandcollection prsbandcol = pgeodataset as irasterbandcollection; /定义波段集irasterband prasterband = prsbandcol.item(0); prasterband.computestatsandhist(); irasterstatistics prasterstatistic = prasterband.statistics; /获取像元统计信息double dmaxvalue = prasterstatistic.maximum ; double dminvalue = prasterstatistic.minimum ; inumberremap pnumremap = new numberremapclass(); /定义inumberremap设定阈值pnumremap.maprange(dminvalue, 0, 0); /设置值区间,输出值pnumremap.maprange(0, dmaxvalue, 1); iremap premap = pnumremap as iremap; /转换成iremapiraster poutraster = preclassop.reclassbyremap(pgeodataset, premap, false) as iraster ; /调用reclassbyremap方法prlayer.createfromraster(poutraster); return prlayer; 栅格图层和矢量图层的属性表浏览 if (plyr is ifeaturelayer) datatable ptable = new datatable(); ifeaturelayer pfealyr = plyr as ifeaturelayer; ifeatureclass pfcls = pfealyr.featureclass; string shape = ; if (pfcls.shapetype = esrigeometrytype.esrigeometrypoint) shape = point; else if (pfcls.shapetype = esrigeometrytype.esrigeometrypolyline) shape = polyline; else if (pfcls.shapetype = esrigeometrytype.esrigeometrypolygon) shape = polygon; for (int i = 0; i pfcls.fields.fieldcount; i+) ptable.columns.add(pfcls.fields.get_field(i).name); ifeaturecursor pcursor = pfcls.search(null, false); int ishape = pfcls.fields.findfield(shape); ifeature pfea = pcursor.nextfeature(); while (pfea != null) datarow prow = ptable.newrow(); for (int i = 0; i pfcls.fields.fieldcount; i+) if (i = ishape) prow = shape; continue; prow = pfea.get_value(i).tostring(); ptable.rows.add(prow); pfea = pcursor.nextfeature(); datagridview1.datasource = ptable; else if (plyr is irasterlayer) irasterlayer prlyr = plyr as irasterlayer; iraster praster = prlyr.raster; irasterprops pprop = praster as irasterprops; pprop.pixeltype = rstpixeltype.pt_long; if (pprop.pixeltype = rstpixeltype.pt_long) irasterbandcollection pbcol = praster as irasterbandcollection; irasterband pband = pbcol.item(0); itable prtable = pband.attributetable; datatable ptable = new datatable(); for (int i = 0; i prtable.fields.fieldcount; i+) ptable.columns.add(prtable.fields.get_field(i).name); icursor pcursor= prtable.search(null, false); irow prrow= pcursor.nextrow(); while (prrow != null) datarow prow = ptable.newrow(); for (int i =0 ;iprrow .fields .fieldcount ;i+) prow = prrow.get_value(i).tostring () ; ptable.rows.add(prow); prrow = pcursor.nextrow(); datagridview1.datasource = ptable; irasterworkspace2 irasterdataset createrasterdataset c# public irasterdataset createfilerasterdataset(string directoryname, string filename) / this function creates a new img file in the given workspace / and then assigns pixel values try irasterdataset rasterdataset = null; ipoint originpoint = new pointclass(); originpoint.putcoords(0, 0); / create the dataset irasterworkspace2 rasterworkspace2 = null; rasterworkspace2 = createrasterworkspace(directoryname); rasterdataset = rasterworkspace2.createrasterdataset(filename, imagine image, originpoint, 200, 100, 1, 1, 1, rstpixeltype.pt_uchar, new unknowncoordinatesystemclass(), true); irawpixels rawpixels = null; ipixelblock3 pixelblock3 = null; ipnt pixelblockorigin = null; ipnt pixelblocksize = null; irasterbandcollection rasterbandcollection; irasterprops rasterprops; / qi for irawpixels and irasterprops rasterbandcollection = (irasterbandcollection)rasterdataset; rawpixels = (irawpixels)rasterbandcollection.item(0); rasterprops = (irasterprops)rawpixels; / create pixelblock pixelblockorigin = new dblpntclass(); pixelblockorigin.setcoords(0, 0); pixelblocksize = new dblpntclass(); pixelblocksize.setcoords(rasterprops.width, rasterprops.height); pixelblock3 = (ipixelblock3)rawpixels.createpixelblock(pixelblocksize); / read pixelblock rawpixels.read(pixelblockorigin, (ipixelblock)pixelblock3); / get pixeldata array system.object, pixeldata; pixeldata = (system.object,)pixelblock3.get_pixeldatabyref(0); / loop through all the pixels and assign value for (int i = 0; i rasterprops.width; i+) for (int j = 0; j rasterprops.height; j+) pixeldatai, j = (i * j) % 255; / write the pixeldata back system.object cachepointer; cachepointer = rawpixels.acquirecache(); rawpixels.write(pixelblockorigin, (ipixelblock)pixelblock3); rawpixels.returncache(cachepointer); / return raster dataset return rasterdataset; catch (exception ex) system.diagnostics.debug.writeline(ex.message); return null; public irasterworkspace2 createrasterworkspace(string pathname) / create rasterworkspace iworkspacefactory workspacefactory = new rasterworkspacefactoryclass(); return workspacefactory.openfromfile(pathname, 0) as irasterworkspace2; #4楼楼主 2009-02-09 15:38 | 尤文之鹤 public irasterdataset tin2raster(string tempbathytin,string geopath, string gridname) string tinfolder = system.io.path.getdirectoryname(tempbathytin); string tinname = system.io.path.getfilename(tempbathytin); irasterdataset rasterdataset = new rasterdatasetclass(); try string rasterpath = system.io.path.getdirectoryname(geopath); iworkspacefactory tinwf = new tinworkspacefactory(); itinworkspace tinwk = tinwf.openfromfile(tinfolder,0)as itinworkspace; itinadvanced2 tinad = tinwk.opentin(tinname) as itinadvanced2; ienvelope extent = tinad.extent; ipoint origin = extent.lowerleft; origin.x = origin.x - (5 * 0.5); origin.y = origin.y - (5 * 0.5); int ncol = (int)math.round(extent.width / 5) + 1; int nrow = (int)math.round(extent.height / 5) +1; ispatialreference2 spatialref = (ispatialreference2)extent.spatialreference; iworkspacefactory rasterwf = new rasterworkspacefactoryclass(); irasterworkspace2 workspace = (irasterworkspace2)rasterwf.openfromfile(rasterpath,0); rasterdataset = workspace.createrasterdataset(gridname, grid, origin,ncol,nrow,5,5,1,esri.arcgis.geodatabase.rstpixeltype.pt_float, spatialref,true); irasterbandcollection bandcoll = (irasterbandcollection) rasterdataset; irasterband rasterband = bandcoll.item(0); irawpixels rawpixels = (irawpixels)rasterband; ipnt blocksize = new dblpntclass(); blocksize.x = ncol; blocksize.y = nrow; ipixelblock3 pixelblock = (ipixelblock3)rawpixels.createpixelblock(blocksize); itinsurface tinsurface = (itinsurface)tinad; irasterprops rasterprops = (irasterprops)rawpixels; object nodatafloat; /long nodataint; object val = pixelblock.get_pixeldatabyref(0); messagebox.show(val.tostring(); double cellsize = 5; origin.x = origin.x + (5 * 0.5); origin.y = origin.y + (5 * nrow) - (5 * 0.5); nodatafloat = convert.todouble(rasterprops.nodatavalue.tostring(); tinsurface.querypixelblock(origin.x,origin.y,cellsize,cellsize,esrirasterizationtype.esrielevationasraster,nodatafloat,val); ipnt offset = new dblpntclass(); offset.x = 0; offset.y = 0; rawpixels.write(offset,pixelblock as ipixelblock); catch(exception ex) messagebox.show(ex.tostring(); return rasterdataset; ilayer player = paxmapcontrol.get_layer(this.cmblayer.selectedindex); irasterlayer pr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 菏泽中考试卷真题及答案
- 2025年中国无线网络设备行业市场分析及投资价值评估前景预测报告
- 2025国考哈尔滨市公安执法岗位申论高频考点及答案
- 2025国考广西统计局行测政治理论必刷题及答案
- 2025国考铁岭市党务工作岗位申论预测卷及答案
- 2025国考丹东市统计调查岗位申论题库含答案
- 2025国考包头市司法行政岗位行测预测卷及答案
- 2025国考包头市信访接待岗位申论预测卷及答案
- 2025国考沈阳市德语翻译岗位申论预测卷及答案
- 2025国考安徽统计局申论公文写作预测卷及答案
- DB32/T 3722-2020高标准农田建设项目可行性研究报告编制规程
- 耳石症教学课件
- 学生心理健康一生一策档案表
- 《淡水生态系统之谜》课件
- 王之涣《登鹳雀楼》课件2
- 北师大版小学五年级数学下册教案全册
- 中国少年先锋队成长故事征文
- 种草养鹅项目实施计划方案
- 动物遗传繁育知到智慧树章节测试课后答案2024年秋甘肃畜牧工程职业技术学院
- 无人机网络安全防护-洞察分析
- T-EERT 040.1-2024 环保设备设施安全管理 总则
评论
0/150
提交评论