Finding maximum pixel value

Discussion created by priyanka_mehta on Apr 17, 2011
Latest reply on May 30, 2011 by priyanka_mehta
Hi all,

     I am trying to search for maximum pixel value in a raster within a defined search buffer and also at each degree from the source point.

So basically, if the source point is x,y . Starting from x,y, I want it to search maximum pixel value in 0°, 2°, 4° etc. till it reaches the buffer extent,  and the coordinates where maximum value is found.

Right now I am doing that by looping it and going to each pixel, checking its pixel value, comparing it to last value and then assigning the maximum. The code works, but at snail's pace.

I tried using IRasterstatistics and also tried exploring skipfactorX and y... but can seem to work it out.

My current code is in vba..
and it goes something like :

  For iRowCount = 0 To pRasterLayer.RowCount - 1
        For iColCount = 0 To pRasterLayer.ColumnCount - 1
            x = pRaster2.ToMapX(iColCount)
            y = pRaster2.ToMapY(iRowCount)

  Xle = Xle + 1
arrX(Xle) = x
arrY(Xle) = y

Next  iColCount
Next iRowCount

for q = 0 to xle

for dangle = 0 to 359 step 2

 ExtentX = 200 * Sin(rAngle)   ''200 is the search buffer distance. I am actually taking it from the user defined text box value
 ExtentY = 200 * Cos(rAngle)

    ExtentX = arrX(q) + ExtentX
    ExtentY = arrY(q) + ExtentY

  x2 = arrX(q)
 y2 = arrY(q)

 do until x2 = extentx and y2 = extenty

   ---- look through each pixel (Ipixelblock)
 ---- compare
---- assign max



Another limitation with this code is that I have used arrays.
For a large raster and fine resolution, the size of the arrays exceeds to the limit where it gives me

runtime error : out of memory.
So I am stuck with using coarse resolution raster.

Please help