rasterWord文件下载.docx

上传人:b****6 文档编号:20444843 上传时间:2023-01-23 格式:DOCX 页数:16 大小:26.98KB
下载 相关 举报
rasterWord文件下载.docx_第1页
第1页 / 共16页
rasterWord文件下载.docx_第2页
第2页 / 共16页
rasterWord文件下载.docx_第3页
第3页 / 共16页
rasterWord文件下载.docx_第4页
第4页 / 共16页
rasterWord文件下载.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

rasterWord文件下载.docx

《rasterWord文件下载.docx》由会员分享,可在线阅读,更多相关《rasterWord文件下载.docx(16页珍藏版)》请在冰豆网上搜索。

rasterWord文件下载.docx

);

return;

}

IRasterWorkspacerastWork=(IRasterWorkspace)workspace;

IRasterDatasetrastDataset;

rastDataset=rastWork.OpenRasterDataset(inName);

//inName栅格文件名

if(rastDataset==null)

Couldnotopentherasterdataset."

5、如何读取栅格数据的属性和遍历栅格数据

栅格数据的属性包括栅格大小,行数,列数,投影信息,栅格范围等等,见下面代码

(假设当前加载的栅格文件栅格值存储方式为:

UShort类型)

IRasterPropsrasterProps=(IRasterProps)clipRaster;

intdHeight=rasterProps.Height;

//当前栅格数据集的行数

intdWidth=rasterProps.Width;

//当前栅格数据集的列数

doubledX=rasterProps.MeanCellSize().X;

//栅格的宽度

doubledY=rasterProps.MeanCellSize().Y;

//栅格的高度

IEnvelopeextent=rasterProps.Extent;

//当前栅格数据集的范围

rstPixelTypepixelType=rasterProps.PixelType;

//当前栅格像素类型

IPntpntSize=newPntClass();

pntSize.SetCoords(dX,dY);

IPixelBlockpixelBlock=clipRaster.CreatePixelBlock(pntSize);

IPntpnt=newPntClass();

for(inti=0;

i<

dHeight;

i++)

for(intj=0;

j<

dWidth;

j++)

pnt.SetCoords(i,j);

clipRaster.Read(pnt,pixelBlock);

if(pixelBlock!

=null)

objectobj=pixelBlock.GetVal(0,0,0);

MessageBox.Show(Convert.ToUInt32(obj).ToString());

6、如何提取指定的范围的栅格数据

提取指定范围内的栅格数据通常用两种方法IRasterLayerExport(esriCarto),IExtractionOp,IExtractionOp2(esriSpatialAnalyst),IRasterLayerExport接口提供的栅格数据提取功能有限,只能以矩形范围作为提取范围,而IExtractionOp接口提供了多边形,圆,属性,矩形等几种形式作为提取栅格数据.

1).IRasterLayerExport接口

IRasterLayerExportrLayerExport=newRasterLayerExportClass();

rLayerExport.RasterLayer=rasterLayer;

//rasterLayer指当前加载的栅格图层

rLayerExport.Extent=clipExtent;

//clipExtent指提取栅格数据的范围

if(proSpatialRef!

rLayerExport.SpatialReference=proSpatialRef;

//proSpatialRef当前栅格数据的投影信息

IWorkspaceFactorypWF=newRasterWorkspaceFactoryClass();

try

IWorkspacepRasterWorkspace=pWF.OpenFromFile(_folder,0);

//_folder指栅格文件保存路径

IRasterDatasetoutGeoDataset=rLayerExport.Export(pRasterWorkspace,code,strRasterType);

//调用ISaveAs接口将导出的数据集保存

……………………..

Catch(Exceptionex)

ThrownewArgumention(ex.Message);

2.IExtractionOp接口(调用此接口前,应该先检查空间许可)

IExtractionOpextraction=newRasterExtractionOpClass();

IGeoDatasetgeoDataset=extraction.Rectangle((IGeoDataset)clipRaster,clipExtent,true);

IRasterraster=geoDatasetasIRaster;

if(raster!

IWorkspaceFactoryWF=newRasterWorkspaceFactoryClass();

IWorkspacerasterWorkspace=WF.OpenFromFile(_folder,0);

ISaveAssaveAs=(ISaveAs)raster;

saveAs.SaveAs(“Result.tif”,rasterWorkspace,"

TIFF"

catch(Exceptionex)

MessageBox..Show(Ex.message);

7.栅格数据重采样

栅格数据的重采样主要基于三种方法:

最邻近采样(NEAREST),双线性

ILINEAR)和三次卷积采样(CUBIC)。

(1).最邻近采样:

它用输入栅格数据中最临近栅格值作为输出值。

因此,在重采

样后的输出栅格中的每个栅格值,都是输入栅格数据中真实存在而未加任何改变的值。

这种方法简单易用,计算量小,重采样的速度最快。

(2).双线性采样:

此重采样法取待采样点(x,y)点周围四个邻点,在y方向(或X方向)内插两次,再在x方向(或y方向)内插一次,得到(x,y)点的栅格值。

(3).三次卷积采样:

这是进一步提高内插精度的一种方法。

它的基本思想是增加邻点来获

得最佳插值函数。

取待计算点周围相邻的16个点,与双线性采样类似,可先在某一方向上内插,如先在x方向上,每四个值依次内插四次,再根据四次的计算结果在y方上内插,最终得到内插结果

代码示例:

采用双线性采样

IRasterGeometryProcrasterGeometryProc=newRasterGeometryProcClass();

rasterGeometryProc.Resample(rstResamplingTypes.RSP_CubicConvolution,newCellSize,clipRaster);

栅格数据重分类(2009-01-1010:

10:

09)

标签:

栅格重分类分类:

AE二次开发

publicstaticIRasterLayerSetViewShedRenderer(IRasterpInRaster,stringsField,stringsPath)

{

IRasterDescriptorpRD=newRasterDescriptorClass();

pRD.Create(pInRaster,newQueryFilterClass(),sField);

IReclassOppReclassOp=newRasterReclassOpClass();

IGeoDatasetpGeodataset=pInRasterasIGeoDataset;

IRasterAnalysisEnvironmentpEnv=pReclassOpasIRasterAnalysisEnvironment;

IWorkspaceFactorypWSF=newRasterWorkspaceFactoryClass();

IWorkspacepWS=pWSF.OpenFromFile(sPath,0);

pEnv.OutWorkspace=pWS;

objectobjSnap=null;

objectobjExtent=pGeodataset.Extent;

pEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue,refobjExtent,refobjSnap);

pEnv.OutSpatialReference=pGeodataset.SpatialReference;

IRasterLayerpRLayer=newRasterLayerClass();

IRasterBandCollectionpRsBandCol=pGeodatasetasIRasterBandCollection;

IRasterBandpRasterBand=pRsBandCol.Item(0);

pRasterBand.ComputeStatsAndHist();

IRasterStatisticspRasterStatistic=pRasterBand.Statistics;

doubledMaxValue=pRasterStatistic.Maximum;

doubledMinValue=pRasterStatistic.Minimum;

INumberRemappNumRemap=newNumberRemapClass();

pNumRemap.MapRange(dMinValue,0,0);

pNumRemap.MapRange(0,dMaxValue,1);

IRemappRemap=pNumRemapasIRemap;

IRasterpOutRaster=pReclassOp.ReclassByRemap(pGeodataset,pRemap,false)asIRaster;

pRLayer.CreateFromRaster(pOutRaster);

returnpRLayer;

栅格图层和矢量图层的属性表浏览

if(pLyrisIFeatureLayer)

DataTablepTable=newDataTable();

IFeatureLayerpFealyr=pLyrasIFeatureLayer;

IFeatureClasspFCls=pFealyr.FeatureClass;

stringshape="

"

;

if(pFCls.ShapeType==esriGeometryType.esriGeometryPoint)

shape="

Point"

elseif(pFCls.ShapeType==esriGeometryType.esriGeometryPolyline)

Polyline"

elseif(pFCls.ShapeType==esriGeometryType.esriGeometryPolygon)

Polygon"

pFCls.Fields.FieldCount;

i++)

pTable.Columns.Add(pFCls.Fields.get_Field(i).Name);

}

IFeatureCursorpCursor=pFCls.Search(null,false);

intishape=pFCls.Fields.FindField("

Shape"

IFeaturepFea=pCursor.NextFeature();

while(pFea!

=null)

DataRowpRow=pTable.NewRow();

if(i==ishape)

pRow[i]=shape;

continue;

pRow[i]=pFea.get_Value(i).ToString();

pTable.Rows.Add(pRow);

pFea=pCursor.NextFeature();

dataGridView1.DataSource=pTable;

elseif(pLyrisIRasterLayer)

IRasterLayerpRlyr=pLyrasIRasterLayer;

IRasterpRaster=pRlyr.Raster;

IRasterPropspProp=pRasterasIRasterProps;

pProp.PixelType=rstPixelType.PT_LONG;

if(pProp.PixelType==rstPixelType.PT_LONG)

IRasterBandCollectionpBcol=pRasterasIRasterBandCollection;

IRasterBandpBand=pBcol.Item(0);

ITablepRTable=pBand.AttributeTable;

pRTable.Fields.FieldCount;

pTable.Columns.Add(pRTable.Fields.get_Field(i).Name);

ICursorpCursor=pRTable.Search(null,false);

IRowpRrow=pCursor.NextRow();

while(pRrow!

for(inti=0;

i<

pRrow.Fields.FieldCount;

i++)

pRow[i]=pRrow.get_Value(i).ToString();

pRrow=pCursor.NextRow();

创建栅格数据集(2008-04-2014:

14:

05)

arcgisenginec#代码it分类:

三文鱼的GIS

关键词:

创建栅格数据集IRasterWorkspace2IRasterDatasetCreateRasterDatasetC#

publicIRasterDatasetCreateFileRasterDataset(stringdirectoryName,stringfileName)

//Thisfunctioncreatesanewimgfileinthegivenworkspace

//andthenassignspixelvalues

try

IRasterDatasetrasterDataset=null;

IPointoriginPoint=newPointClass();

originPoint.PutCoords(0,0);

//Createthedataset

IRasterWorkspace2rasterWorkspace2=null;

rasterWorkspace2=CreateRasterWorkspace(directoryName);

rasterDataset=rasterWorkspace2.CreateRasterDataset(fileName,"

IMAGINEImage"

originPoint,200,100,1,1,1,rstPixelType.PT_UCHAR,newUnknownCoordinateSystemClass(),true);

IRawPixelsrawPixels=null;

IPixelBlock3pixelBlock3=null;

IPntpixelBlockOrigin=null;

IPntpixelBlockSize=null;

IRasterBandCollectionrasterBandCollection;

IRasterPropsrasterProps;

//QIforIRawPixelsandIRasterProps

rasterBandCollection=(IRasterBandCollection)rasterDataset;

rawPixels=(IRawPixels)rasterBandCollection.Item(0);

rasterProps=(IRasterProps)rawPixels;

//Createpixelblock

pixelBlockOrigin=newDblPntClass();

pixelBlockOrigin.SetCoords(0,0);

pixelBlockSize=newDblPntClass();

pixelBlockSize.SetCoords(rasterProps.Width,rasterProps.Height);

pixelBlock3=(IPixelBlock3)rawPixels.CreatePixelBlock(pixelBlockSize);

//Readpixelblock

rawPixels.Read(pixelBlockOrigin,(IPixelBlock)pixelBlock3);

//Getpixeldataarray

System.Object[,]pixelData;

pixelData=(System.Object[,])pixelBlock3.get_PixelDataByRef(0);

//Loopthroughallthepixelsandassignvalue

rasterProps.Width;

rasterProps.Height;

j++)

pixelData[i,j]=(i*j)%255;

//Writethepixeldataback

System.ObjectcachePointer;

cachePointer=rawPixels.AcquireCache();

rawPixels.Write(pixelBlockOrigin,(IPixelBlock)pixelBlock3);

rawPixels.ReturnCache(cachePointer);

//Returnrasterdataset

returnrasterDataset;

catch(Exceptionex)

System.Diagnostics.Debug.WriteLine(ex.Message);

returnnull;

publicIRasterWorkspace2CreateRasterWorkspace(stringpathName)

//CreateRasterWorkspace

IWorkspaceFactoryworkspaceFactory=newRasterWorkspaceFactoryClass();

returnworkspaceFactory.OpenFromFile(pathName,0)asIRasterWo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1