How to identify pixel values on a raster


Identifying pixel values on a raster

IRaster2.GetPixelValue can be used to retrieve a pixel value at a given row and column in a pixel space. To get the pixel value by giving x,y coordinates in a map space, use the following code:
[Java]
static void identifyPixelValue(IRaster raster, double xMap, double yMap)throws
    Exception{
    IRaster2 raster2 = (IRaster2)raster;

    //Get the column and row by giving x,y coordinates in a map space.
    int col = raster2.toPixelColumn(xMap);
    int row = raster2.toPixelRow(yMap);

    //Get the value at a given band.
    Object pixelValue = raster2.getPixelValue(0, col, row);
}






Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine