Ah, I misinterpreted your question. Statistics as Table will not work.
What you actually want is the closest point occurrence of the maximum value from a raster along a given azimuth (it is hard to phrase�?�).
Below is my approach. I use a structure to remember the x, y, azimuth, and raster value for each sample location from the start point to the search radius along a given azimuth. I then sort the collection of structures and pull the max value.
So, if I want to get all the locations for each even azimuth (2, 4, 6,�?�,360) at a search radius of 1000 meters with a sample point at every meter you call the function like:
Dim al as New ArrayList
al = MaxPoints(1000, 1, pPoint, pRaster)
This will return a collection of 180 points (pt structures), one for each even azimuth at the first occurance of the maximum value from the input raster. Runs pretty fast �?? hopefully faster than yours (if I understand the question now�?�).
Sorry if this just adds to the confusion. The code is a little sloppy. I guess if I wanted to be brief I'd say don't use pixel blocks and use pRaster.GetPixelValue(0, col, row)
Structure PT
Implements IComparable
Public X As Double
Public Y As Double
Public Degree As Integer
Public Value As Double
Public Position As Integer 'numeric order of point from center.
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Dim tmpObj As PT = CType(obj, PT)
Return (Me.Value.CompareTo(tmpObj.Value))
End Function
End Structure
Private Function MaxPoints(ByVal BufferRadius As Double, ByVal Interval As Integer, ByVal InPoint As IPoint, ByVal pRaster2 As IRaster2) As ArrayList
'BufferRadius = search distance from center point (pPoint)
'Interval = distance between sample points from center point to bufferradius
' should be more dense than raster cell size...
'InPoint = center point
'pRaster = raster with values for searching max value
Dim al As New ArrayList ' temp array list to hold each sample point from center at given azimuth
Dim finalAl As New ArrayList ' final return arraylist - always 180 points
Dim col As Integer 'column of raster at sample point
Dim row As Integer 'row of raster at sample point
Dim newPT As PT ' structure to remember azimuth, sample point location, and raster cell value
Dim x As Integer
Dim j As Integer
Dim z As Integer = 0
Dim xCoord As Double
Dim yCoord As Double
Dim i As Double
Dim count As Integer
'Get max value for each even azimuth
For x = 2 To 360 Step 2
'Make sample point for every interval out to radius exenet along each even azimuth
Do While z < BufferRadius
xCoord = z * Math.Cos((90 - x) * Math.PI / 180.0F) + InPoint.X
yCoord = z * Math.Sin((90 - x) * Math.PI / 180.0F) + InPoint.Y
'Find corresponding raster cell at sample point location
col = pRaster.ToPixelColumn(xCoord)
row = pRaster.ToPixelRow(yCoord)
'Get pixel value at sample point location.
i = CDbl(pRaster.GetPixelValue(0, col, row))
'Record sample point location, azimuth, and raster pixel value in PT structure.
newPT.Degree = x
newPT.X = xCoord
newPT.Y = yCoord
newPT.Value = i
'Add to arraylist.
al.Add(newPT)
z += Interval
count += 1
Loop
'Sort arraylist of PT structures on value Max value is now at the bottom
al.Sort()
'I know awkward...
'Make sure that final location is the first occurrence i.e. get the last and compare to the next to last...
newPT = CType(al(al.Count - 1), PT)
For j = al.Count - 2 To 0 Step -1
If CType(al(j), PT).Value = newPT.Value Then
If CType(al(j), PT).Position < newPT.Position Then
newPT = CType(al(j), PT)
End If
Else : Exit For
End If
Next
finalAl.Add(newPT)
'Reset variables for next loop.
al.Clear()
z = 0
count = 0
Next
'Final array list will have 180 PT structures - one for each even azimuth at the max cell location.
Return finalAl
End Function