ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data.Raster Namespace / PixelBlock Class / GetNoDataMaskValue Method
Index of a plane from this pixel block
X offset in the given plane
Y offset in the given plane
Example

In This Topic
    GetNoDataMaskValue Method
    In This Topic
    Gets the NoData mask value for the given plane, column and row from this pixel block. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public object GetNoDataMaskValue( 
       int plane,
       int x,
       int y
    )
    Public Function GetNoDataMaskValue( _
       ByVal plane As Integer, _
       ByVal x As Integer, _
       ByVal y As Integer _
    ) As Object

    Parameters

    plane
    Index of a plane from this pixel block
    x
    X offset in the given plane
    y
    Y offset in the given plane

    Return Value

    An object representing the NoData value for the given pixel.
    Remarks
    The NoData mask value allows you to identify whether a specific pixel is NoData or not. A value of 1 means this corresponding pixel has a value and 0 means this corresponding pixel is NoData.
    Example
    Process pixels using a pixel block
    await QueuedTask.Run(() =>
    {
      // Read pixel values from the raster dataset into the pixel block starting from the given top left corner.
      raster.Read(0, 0, currentPixelBlock);
    
      // For each plane (band) in the pixel block
      for (int plane = 0; plane < currentPixelBlock.GetPlaneCount(); plane++)
      {
        // Get a copy of the array of pixels from the pixel block corresponding to the current plane.
        Array sourcePixels = currentPixelBlock.GetPixelData(plane, true);
        // Get the height and width of the pixel block.
        int pBHeight = currentPixelBlock.GetHeight();
        int pBWidth = currentPixelBlock.GetWidth();
    
        // Iterate through the pixels in the array.
        for (int i = 0; i < pBHeight; i++)
        {
          for (int j = 0; j < pBWidth; j++)
          {
            // Get the NoData mask value to see if the pixel is a valid pixel.
            if (Convert.ToByte(currentPixelBlock.GetNoDataMaskValue(plane, j, i)) == 1)
            {
              // Get the pixel value from the array and process it (add 5 to the value).
              // Note: This is assuming the pixel type is Unisigned 8bit.
              int pixelValue = Convert.ToInt16(sourcePixels.GetValue(j, i)) + 5;
              // Make sure the pixel value does not go above the range of the pixel type.
              pixelValue = pixelValue > 254 ? 254 : pixelValue;
              // Set the new pixel value to the array.
              // Note: This is assuming the pixel type is Unisigned 8bit.
              sourcePixels.SetValue(Convert.ToByte(pixelValue), j, i);
            }
          }
        }
        // Set the modified array of pixels back to the pixel block.
        currentPixelBlock.SetPixelData(plane, sourcePixels);
      }
      // 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, Windows 8.1

    See Also