You need to get this book:
Analysing spatial point patterns in R
Adrian Baddeley
CSIRO and University of Western Australia
Adrian.Baddeley@csiro.au
adrian@maths.uwa.edu.au
It's the bible of spatial statistics. You should look at the Morishita plot and Fry plot. They describe the tendency for points of certain classes to avoid or attract each other. Here is a snippet:
18 Exploring dependence between points
Suppose that a point pattern appears to have constant intensity, and we wish to assess whether the pattern is Poisson. The alternative is that the points are dependent (they exhibit ‘interaction’). Classical writers suggested a simple trichotomy between ‘independence’ (the Poisson process), ‘regularity’ (where points tend to avoid each other), and ‘clustering’ (where points tend to be close together). [The concept of ‘clustering’ does not imply that the points are organised into identifiable ‘clusters’; merely that they are closer together than expected for a Poisson process.]
One simple diagnostic for dependence between points is a Morishita plot. The spatial domain is divided into quadrats, and the 2 statistic based on quadrat counts is computed. The quadrats are repeatedly subdivided. The Morishita plot shows the 2 statistic against the linear size of the quadrats.
A more sophisticated option is the Fry plot. This is a scatterplot of the vector differences xj − xi between all pairs of distinct points in the pattern. Suppose you have printed the point pattern on a sheet of paper. Take a sheet of tracing paper, and mark a red dot in the middle. Now place the tracing paper over the point pattern, and move it until the red dot coincides with one of the data points. Now copy all the other data points onto the tracing paper. Repeat this for every data point, and you have the Fry plot.
Below is code to construct the Fry plot from xPoints and yPoints. It gets them from a binary image. If you already have the points, you can skip that and use your points.
[rows, columns] = size(binaryImage);
fryPlot = zeros(2 * rows, 2 * columns);
[yPoints, xPoints] = find(binaryImage);
radialProfile = zeros(1, round(2 * sqrt(rows^2 + columns^2)));
sumOfRadii = 0;
numPoints = length(yPoints);
for p1 = 1 : numPoints
for p2 = 1 : numPoints
if p2 == p1
continue;
end
deltaRow = yPoints(p2) - yPoints(p1) + rows;
deltaCol = xPoints(p2) - xPoints(p1) + columns;
fryPlot(deltaRow, deltaCol) = fryPlot(deltaRow, deltaCol) + 1;
radius = sqrt((deltaRow - rows)^2 + (deltaCol - columns)^2);
index = round(radius)+1;
radialProfile(index) = radialProfile(index) + 1;
sumOfRadii = sumOfRadii + radius;
end
end
meanRadius = sumOfRadii / (numPoints * (numPoints-1));
figure;
subplot(2, 2, 1);
fryPlot(rows, columns) = 0;
neighboringMean = mean(fryPlot(rows-2, columns-1:columns+1));
fryPlot(rows-1:rows+1, columns-1:columns+1) = neighboringMean;
imshow(fryPlot, []);
title('Fry Plot', 'FontSize', fontSize);
hold on;
viscircles([columns, rows], meanRadius);
subplot(2, 2, 2);
histogram(fryPlot(fryPlot>0));
grid on;
title('Histogram of Radii in Fry Plot', 'FontSize', fontSize);