Represents a raster dataset consisting of a rectangular grid of cells arranged into rows and columns, and composed of single or multiple bands. In the context of a geodatabase a Raster object represents a raster whereas when accessing data in a directory it represents any of the supported, file-based, raster formats.

Namespace:  ESRI.ArcGISExplorer.Data

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public sealed class Raster : IDisposable
Visual Basic (Declaration)
Public NotInheritable Class Raster _
	Implements IDisposable

Remarks

A Raster object can be created in a number of different ways depending on the data source type:

  • From the Geodatabase.OpenRaster method when opening a geodatabase raster.
  • From the DataDirectory.OpenRaster method when opening raster file.
  • From the static methods on the Raster class. To open a geodatabase raster use OpenFileGeodatabaseRaster, or OpenArcSDERaster. To open a file-based raster use OpenRasterFile.
  • From a RowValueCollection for a raster Column in a Table. The value will be returned as an Object but can be cast to a Raster.

You can find out about the dimensions of a Raster (RowCount, ColumnCount , and CellSize), the maximum extent of the cells (Extent) and the coordinate system in which the data is stored (CoordinateSystem). You can also find out how many bands a Raster is composed of and return their names using the BandCount property and the GetBandNames method respectively.

You can find out the display color or the value of a cell at a particular location using the GetColorAtPoint and GetValueAtPoint methods respectively. To return either a full size or scaled version of a Raster as a Windows Bitmap you can use the GetBitmap method.

Raster pyramids are series of reduced resolution representations of the dataset, mainly used to improve the display performance of rasters; you can check whether pyramids exist using the HasPyramids property and build pyramids using the BuildPyramids method.

Geodatabase raster catalogs and file-base image catalogs are not supported and cannot be opened.

Examples

The code below provides two examples of using the Raster class. The first performs an analysis on a file-based raster using the GetValueAtPoint method, whereas the second accesses a photo stored in a Raster Column of a geodatabase feature class and from which a thumbnail image is created using the GetBitmap method.
CopyC#
{
  //Example 1 - Perform an analysis of the vegetation types encountered while
  //hiking the Continental Divide Trail through Yellowstone National Park
  //*************************************************************************

  //Open raster file of vegetation classifications
  Raster vegetationRaster = Raster.OpenRasterFile(@"C:\Data\Yellowstone\veg.img");

  //Open feature class of the Continental Divide Trail
  Table trailTable = Table.OpenFileGeodatabaseTable(@"C:\Data\Yellowstone\Yellowstone.gdb", "Trail");

  //Create a List to store vegetation type codes
  List<double> vegCodes = new List<double>();

  //Loop over all the rows which make up the trail
  foreach (Row trailRow in trailTable.GetRows())
  {
    //Get the geometry for each Row
    Polyline trailGeometry = trailRow.Geometry as Polyline;

    //Loop over each vertex Point (all Polylines are single-part)
    foreach (ESRI.ArcGISExplorer.Geometry.Point vertex in trailGeometry.GetPath(0))
    {
      //Return the cell value at each Point
      vegCodes.Add(vegetationRaster.GetValueAtPoint(vertex));
    }
  }

  //Create another List of unique vegetation types encountered
  //Alternatively if .NET Framework 3.5 is installed : List<double> trailVegCodes = vegCodes.Distinct().ToList();
  List<double> trailVegCodes = new List<double>();
  foreach (double value in vegCodes)
  {
    if (trailVegCodes.Contains(value))
      continue;
    trailVegCodes.Add(value);
  }

  //Example 2 - Search for photo of a specific campsite
  //***************************************************

  //Open feature class of campsites
  Table campsitesTable = Table.OpenFileGeodatabaseTable(@"C:\Data\Yellowstone\Yellowstone.gdb", "Campsites");

  //Find the Indian Creek campsite
  Row indianCreekCamp = campsitesTable.Search(new Filter("NAME='Indian Creek'")).GetFirst();

  //Retrieve the photo of the camp as a Raster from the Photo Column
  Raster indianCreekCampPhoto = indianCreekCamp.Values["Photo"] as Raster;

  //Resize the photo to make it a thumbnail
  System.Drawing.Bitmap photoThumbnail = indianCreekCampPhoto.GetBitmap(64, 64);
}
CopyVB.NET
'Example 1 - Perform an analysis of the vegetation types encountered while
      'hiking the Continental Divide Trail through Yellowstone National Park
'*************************************************************************


'Open raster file of vegetation classifications
Dim vegetationRaster As Raster = Raster.OpenRasterFile("C:\Data\Yellowstone\veg.img")

      'Open feature class of the Continental Divide Trail
Dim trailTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\Yellowstone\Yellowstone.gdb", "Trail")

'Create a List to store vegetation type codes
Dim vegCodes As List(Of Double) = New List(Of Double)()

'Loop over all the rows which make up the trail
For Each trailRow As Row In trailTable.GetRows()
  'Get the geometry for each Row
  Dim trailGeometry As Polyline = DirectCast(trailRow.Geometry, Polyline)

  'Loop over each vertex Point (all Polylines are single-part)
  For Each vertex As ESRI.ArcGISExplorer.Geometry.Point In trailGeometry.GetPath(0)
    'Return the cell value at each Point
    vegCodes.Add(vegetationRaster.GetValueAtPoint(vertex))
  Next
Next

'Create another List of unique vegetation types encountered
      'Alternatively if .NET Framework 3.5 is installed : Dim trailVegCodes As List(Of Double) = vegCodes.Distinct().ToList()
Dim trailVegCodes As List(Of Double) = New List(Of Double)
For Each value As Double In vegCodes
  If trailVegCodes.Contains(value) Then
    Continue For
  End If
  trailVegCodes.Add(value)
Next

'Example 2 - Search for photo of a specific campsite
'***************************************************


'Open feature class of campsites
Dim campsitesTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\Yellowstone\Yellowstone.gdb", "Campsites")

'Find the Indian Creek campsite
Dim indianCreekCamp As Row = campsitesTable.Search(New Filter("NAME='Indian Creek'")).GetFirst()

'Retrieve the photo of the camp as a Raster from the Photo Column
Dim indianCreekCampPhoto As Raster = DirectCast(indianCreekCamp.Values.Item("Photo"), Raster)

'Resize the photo to make it a thumbnail
Dim photoThumbnail As System.Drawing.Bitmap = indianCreekCampPhoto.GetBitmap(64, 64)

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Data..::.Raster

See Also