public static IEnumerable <IPixelBlock> PixelBlocks(this IRaster raster) { var cursor = raster.CreateCursor(); while (cursor.Next()) { yield return(cursor.PixelBlock); } }
public void CanGetRasterFromMosaicDataset() { IWorkspace workspace = TestUtils.OpenUserWorkspaceOracle(); IMosaicDataset dataset = DatasetUtils.OpenMosaicDataset(workspace, "TOPGIS_TLM.TLM_DTM_MOSAIC"); IRaster raster = ((IMosaicDataset3)dataset).GetRaster(string.Empty); Assert.NotNull(dataset); IRasterCursor rasterCursor = raster.CreateCursor(); IPixelBlock rasterCursorPixelBlock = rasterCursor.PixelBlock; Assert.NotNull(rasterCursorPixelBlock); }
void GetRasterCursorDefault(IRaster pRaster) { IRasterCursor pRasterCursor = pRaster.CreateCursor(); while (pRasterCursor.Next()) { IPixelBlock pPixBlock = pRasterCursor.PixelBlock; int W = pPixBlock.Width; //这个W也就是整个栅格数据记得宽度 int H = pPixBlock.Height; } }