来自:http://www.cnblogs.com/kisstome88/archive/2009/04/05/1429812.html
得到Raster的一些基本信息(高程值,列数,列数)
IRasterLayer pRasterLayer = (IRasterLayer)pSC1.Scene.get_Layer(0);
IRaster pRaster = pRasterLayer.Raster;
int pRowCount = pRasterLayer.RowCount;
IRasterBandCollection pRasterbandCollection = (IRasterBandCollection)pRaster;
IRasterBand pRasterBand = pRasterbandCollection.Item(0);
IRawPixels pRawPixels = (IRawPixels)pRasterBand;
IRasterProps pRProps = (IRasterProps)pRawPixels;
IRasterAnalysisProps pRasterAP = (IRasterAnalysisProps)pRaster;
//获得DEM左上角的坐标
IGeoDataset pGeoDataset = (IGeoDataset)pRaster;
IEnvelope2 pEnv2 = new EnvelopeClass();
pEnv2 = (IEnvelope2)pGeoDataset.Extent;
IPoint pPoint = pEnv2.UpperLeft;
//用经纬度表示的DEM源点X坐标
double pOriginX = pPoint.X; //DEM源点X坐标(左上角点)
double pOriginY = pPoint.Y; //DEM源点Y坐标
//MessageBox.Show(Convert.ToString(pOriginX)+" "+Convert .ToString (pOriginY ));
IRasterStatistics pRasterStatics = pRasterBand.Statistics;
double m_MaxHeight = pRasterStatics.Maximum; //DEM最大的高程值
double pBlockX = (double)pRProps.MeanCellSize().X; //网格的X间距
double pBlockY = (double)pRProps.MeanCellSize().Y; //网格的Y间距
double pBlockArea = pBlockX * pBlockY; //网格的面积
int pColumns = pRProps.Width; //DEM列数
int pRows = pRProps.Height; //DEM行数
IPnt pBlockSize = new DblPntClass();
pBlockSize.X = pColumns;
pBlockSize.Y = pRows;
IPixelBlock3 pPixelBlock = (IPixelBlock3)pRawPixels.CreatePixelBlock(pBlockSize);
IPnt pBlockOrigin = new DblPntClass();
pBlockOrigin.X = 0;
pBlockOrigin.Y = 0;
pRawPixels.Read(pBlockOrigin, (IPixelBlock)pPixelBlock);
double pHeight = pPixelBlock.Width;
//存储格网DEM的二维数组
System.Array pPixelData = (System.Array)pPixelBlock.get_PixelDataByRef(0);
用pPixelData.GetValue(j, k)来获得每一个栅格的高程值