ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data.Raster Namespace / RasterCursor Class
Members Example

In This Topic
    RasterCursor Class
    In This Topic
    Represents a cursor that provides optimized raster access.
    Object Model
    RasterCursor ClassPixelBlock Class
    Syntax
    public sealed class RasterCursor : ArcGIS.Core.CoreObjectsBase, System.IDisposable  
    Public NotInheritable Class RasterCursor 
       Inherits ArcGIS.Core.CoreObjectsBase
       Implements System.IDisposable 
    Remarks
    The RasterCursor controls enumeration through the PixelBlocks in a Raster. It is useful for rasters that are too large to be brought into memory at once.
    Example
    Create a raster cursor to iterate through the raster data
    await QueuedTask.Run(() =>
    {
      // Create a full raster from the raster dataset.
      ArcGIS.Core.Data.Raster.Raster raster = rasterDataset.CreateFullRaster();
    
      // Calculate size of pixel blocks to process. Use 1000 or height/width of the raster, whichever is smaller.
      var height = raster.GetHeight();
      var width = raster.GetWidth();
      int pixelBlockHeight = height > 1000 ? 1000 : height;
      int pixelBlockWidth = width > 1000 ? 1000 : width;
    
      // Create the raster cursor using the height and width calculated.
      RasterCursor rasterCursor = raster.CreateCursor(pixelBlockWidth, pixelBlockHeight);
    
      // Use a do-while loop to iterate through the pixel blocks of the raster using the raster cursor.
      do
      {
        // Get the current pixel block from the cursor.
        using (PixelBlock currentPixelBlock = rasterCursor.Current)
        {
          // Do something with the pixel block...
        }
    
        // Once you are done, move to the next pixel block.
      }
      while (rasterCursor.MoveNext());
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Raster.RasterCursor

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also