ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data.Raster Namespace / Raster Class / CreatePixelBlock Method
Width of the pixel block to create.
Height of the pixel block to create.
Example

In This Topic
    CreatePixelBlock Method
    In This Topic
    Create a PixelBlock of the given width and height. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public PixelBlock CreatePixelBlock( 
       int width,
       int height
    )
    Public Function CreatePixelBlock( _
       ByVal width As Integer, _
       ByVal height As Integer _
    ) As PixelBlock

    Parameters

    width
    Width of the pixel block to create.
    height
    Height of the pixel block to create.

    Return Value

    A PixelBlock of the given width and height.
    Example
    Read and Write pixels from and to a raster dataset using pixel blocks
    await QueuedTask.Run(() =>
    {
      // Create a full raster from the raster dataset.
      ArcGIS.Core.Data.Raster.Raster raster = rasterDataset.CreateFullRaster();
    
      // Calculate size of pixel block to create. Use 128 or height/width of the raster, whichever is smaller.
      var height = raster.GetHeight();
      var width = raster.GetWidth();
      int pixelBlockHeight = height > 128 ? 128 : height;
      int pixelBlockWidth = width > 128 ? 128 : width;
    
      // Create a new (blank) pixel block.
      PixelBlock currentPixelBlock = raster.CreatePixelBlock(pixelBlockWidth, pixelBlockHeight);
    
      // Read pixel values from the raster dataset into the pixel block starting from the given top left corner.
      raster.Read(0, 0, currentPixelBlock);
    
      // Do something with the pixel block...
    
      // Write the pixel block to the raster dataset starting from the given top left corner.
      raster.Write(0, 0, currentPixelBlock);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also