I have a point file, hourly relocations of an animal, and I want to be able to place a buffer around each point and calculate the number of subsequent points which are within the buffer zone. I am looking for a method which will work along the point file, like a moving window, which will only count those subsequent points which are within the buffer zone.
For instance at point 10 I place a buffer of 1500m and I want to know whether point 11 is within the buffer and if so then whether point 12 is within the buffer and so forth. I don't want to know whether point 52 is within the buffer zone unless all of the previous points have been within the buffer. I also don't want to know whether points 9 or 8 etc. are within the buffer.
I have found and tried an additional toolbox called "moving window point analysis" which works as a moving window on the point file. This works well, but very slowly, and includes all points that are within the buffer zone even if they are not consecutive points. I can't find a way to just make it look at consecutive points.
I would like a method which will provide an output table as I have a lot of data points to look at in this way.
I am using ArcGIS 10. Any help that anyone can provide would be greatly appreciated.
Best Answer
Given a list of point locations (preferably in projected coordinates, so that distances are easy to compute), this problem can be solved with five simpler operations:
Compute point-point distances.
For each point i, i = 1, 2, ..., identify the indexes of those points at distances less than the buffer radius (such as 1500).
Restrict those indexes to be i or greater.
Retain only the first consecutive group of indexes having no break.
Output the count of that group.
In
R
, each of these corresponds to one operation. To apply this sequence to each point, it's convenient to encapsulate most of the work within a function we define, thus:(See below for a more efficient version of this function.)
I have made this function flexible enough to accept various point lists (
xy
) and buffer distances (r
) as parameters.Normally, you would read a file of point locations (and, if necessary, sort them by time). Here, to show this in action, we will just generate some sample data randomly:
Their typical spacing is 300*Sqrt(2) = about 500. We do the calculation by applying this function to the points in the array
xy
(and then tacking its results back on toxy
, because this would be a convenient format for export to a GIS):You would then further analyze the
result
array, either inR
or by writing it to a file and importing it into other software. Here is the result for the sample data:(Remember that the counts include the points at which they are based, so that each count must be 1 or greater.)
If you have many thousands of points, this method is too inefficient: it computes far too many point-to-point distances that are unnecessary. But because we have encapsulated the work within the
forward
function, the inefficiency is straightforward to fix. Here is a version that will work better when more than a few hundred points are involved:To test this, I created random points as previously but varied two parameters:
n
(the number of points) and their standard deviation (hard-coded as 300 above). The standard deviation determines the average number of points within each buffer ("average" in the table below): the more there are, the longer this algorithm takes to run. (With more sophisticated algorithms the run time won't depend as much on how many points are in each buffer.) Here are some timings: