『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcGIS Engine 10 开发手册(8-9)示例:栅格数据分块

ArcGIS Engine 10 开发手册(8-9)示例:栅格数据分块
我们知道栅格数据往往是很大的,为了提高处理的效率,我们有的时候需要将栅格数据分块。

    我们知道栅格数据往往是很大的,为了提高处理的效率,我们有的时候需要将栅格数据分块,处理每 一个小块的数据,然后在需要的时候进行合并,当然 ArcGIS 的工具箱直接提供了这个工具,下面是我们 通过代码实现类似的功能。

 

/// <summary>

 

/// 分割栅格数据

 

/// </summary>

 

/// <param name="pRasterDataset"></param>

 

/// <param name="pOutputWorkspace"></param>

 

/// <param name="pWidth"></param>

 

/// <param name="pHeight"></param>

 

public void CreateTilesFromRasterDataset (IRasterDataset pRasterDataset, IWorkspace pOutputWorkspace, int pWidth, int pHeight)

 

{

 

  IRasterProps pRasterProps = (IRasterProps) pRasterDataset.CreateDefaultRaster ();

 

  double xTileSize = pRasterProps.MeanCellSize ().X * pWidth;

  double yTileSize = pRasterProps.MeanCellSize ().Y * pHeight;

 

  int xTileCount = (int) Math.Ceiling ((double) pRasterProps.Width / pWidth);

  int yTileCount = (int) Math.Ceiling ((double) pRasterProps.Height / pHeight);

 

  IEnvelope pExtent = pRasterProps.Extent;

  IEnvelope pTileExtent = new EnvelopeClass ();

  ISaveAs pSaveAs = null;

 

  for (int i = 0; i < xTileCount; i++)

 

  {

 

    for (int j = 0; j < yTileCount; j++)

 

    {

 

      pRasterProps = (IRasterProps) pRasterDataset.CreateDefaultRaster ();

 

      pTileExtent.XMin = pExtent.XMin + i * xTileSize;

      pTileExtent.XMax = pTileExtent.XMin + xTileSize;

 

      pTileExtent.YMin = pExtent.YMin + j * yTileSize;

      pTileExtent.YMax = pTileExtent.YMin + yTileSize;

 

      pRasterProps.Height = pHeight;

      pRasterProps.Width = pWidth;

      pRasterProps.Extent = pTileExtent;

 

    }

 

    pSaveAs = (ISaveAs) pRasterProps;

 

    pSaveAs.SaveAs ("tile_" + i + "_" + j + ".tif", pOutputWorkspace, "TIFF");

 

  }

 

}

      京ICP备08100627号-22 京公网安备 11010802030428号