# Finding clusters of one set of points around another set of points from different layer?

I want to see if there is clustering of a certain type of buildings (x) around another type of buildings (y).

The two point files are in different layers.

I cannot figure out which tool I would use to do this.

-

None of the out-of-the-box tools in ArcGIS (or any other GIS, AFAIK) will do the job correctly.

In a problem like this you need to quantify what you mean by "clustering" and then you need to posit a probability model to assess whether the measured degree of clustering could have been produced by accidental chances.

As an example of how to proceed, you might choose to measure clustering in terms of typical distances between buildings of type x and the nearest building of type y. This is an easy calculation: simply represent both sets of buildings by separate point layers and perform a spatial join of the Y's to the X's. The attribute table, which still has one record for each type x building, will now include the distance to the nearest y. You could use the average distance as your measure.

Testing whether this could be the result of chance is trickier. One plausible interpretation of this setting is that the earlier presence of y type buildings encouraged the development of x type buildings relatively close to the y's. Otherwise, we might hypothesize that the x type buildings could have been built anywhere that other buildings also appeared. This leads to the following simple permutation test. Create a point layer of all possible locations where x type buildings might have appeared. This layer could be the locations of all buildings in the area erected during the same period as the x buildings were (including the x buildings themselves, of course). Spatially join the y layer to obtain the distances to the nearest y type building. The rest of the calculation works off the attribute table: the geographic calculations are done. What you will do is repeatedly use a random number generator to take a simple random sample of all of these buildings, each sample having exactly as many elements as you have x type buildings. Compute the average distance for this sample. Repeat until you have many average-distance statistics. If almost all these randomly obtained average distances are greater than the average distance you measured for the x type buildings, you can conclude that the x's are not clustered by chance: the effect is real.

(Such calculations are best programmed on a platform suited to such purposes, such as `R', but almost any computing software can be pressed into service, even Excel. The programming is very, requiring little more than knowing how to write loops and select elements from arrays at random.)

This permutation testing approach is superior to pre-programmed solutions because it explicitly accounts for the patterns of building development in this area. If you don't do this, you often will find "significant" evidence of clustering, but you can't conclude anything useful from it, because the clustering may have been caused by other factors such as the patterns of roads, the locations of sites suitable for development, and many other things.

-
I realize this reply is a little abstract. When I have more time I'll try to create a realistic illustration. – whuber May 1 '11 at 21:11
For those using R, I'd recommend giving the spatstat package (cran.r-project.org/web/packages/spatstat/index.html) a look for cluster analysis. – om_henners May 4 '11 at 7:30

Of course, your data analysis method should depend on the substantive problem motivating the analysis.

But here are some ideas:

## From ESRI:

How Multi-Distance Spatial Cluster Analysis: Ripley's k-function (Spatial Statistics) works , where i and j in the equation would denote your buildings x and y. Ripley's K-function will provide probabilistic inference.

## From computer science:

There are complex algorithms for co-location pattern discovery that you can google.

-
The "simple plot idea" is interesting but you need something to compare it to: by itself it's difficult to extract useful information from it. Ripley's K function is a useful tool, too, but unfortunately in many cases it merely reflects the geometry of the dataset. With houses in a suburban or rural area, which tend to lie along linear features (roads), the K function will clearly show "significant" clustering for this reason alone. As such it reveals nothing useful about houses other than that they are built near roads! – whuber May 2 '11 at 14:11
@whuber 1st thanks for the explanation of the problem of Ripley's K function. 2nd, when we see a plot of stock prices over time, we can look for general trends up or down or random, also we can pick-out times that there were large decreases or increases and ask why. A plot of how the concentration of buildings changes as distance changes can be used in the same manner. It can be used to search for spikes in concentration, which is evidence against a random distribution, also it can be used to focus further investigation of curious spikes. – b_dev May 3 '11 at 3:35
You're right. My point is that the plot in and of itself tells us nothing about clustering. Perhaps a good analogy (rather than stock prices) is choropleth map of numbers of kidney cancer cases by state 2000-2010 in the US. That, too, tells us nothing about (geographic) clustering because it does not account for variations in population between states. Similarly, a cross-K plot needs a suitable normalization or reference to be interpretable. The general trends, spikes, etc., might just be reflecting the geographic patterns of all building locations. – whuber May 3 '11 at 3:40
@whuber You're right. After reading your above comment, I have decided my Simple Plot Idea will not provide much information, at least as it was described, so I have removed it so as not to confuse people. I now believe Joint Count Statistic is the simplest method to approach the problem. – b_dev May 4 '11 at 3:01

I've never done cluster analysis in GIS myself, but would it may be easier if you created points/polygons to represent a given cluster of X and/or Y. For example, if you created points to signify building Y , you could then use the Point Distance tool to get all points of building X within a given distance from your origin locations.

Otherwise, creating a buffer around buildings of type Y and selecting all buildings of type X will achieve the same result if you don't have ArcInfo.

-

You could combine both layers by adding a binary column (0,1) to identify whether the building is from X or Y.

From there using GeoDa you could identify local spatial auto-correlation (clustering) and determine whether it was high-low (one layer clustered around the other layer) low-high (the inverse) or high-high or low-low (self-clustering). User's guide here (.pdf)

-