Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the shape file for DC PSA's as defined in 2012 (see below). I would like to be able to identify in semi-automatic fashion which PSA's are neighbors - that is, which PSA's are nearest neighbors to one another (for example, 201 and 401 are nearest neighbors).

With this information, one could define a sort of spatial distance metric between PSA $i$ and PSA $j$, call it $d(i,j)$, populating a distance matrix, call it $D$. Then $d(i,j)=0$ is pure autocorrelation (it is the diagonal of $D$). If $d(i,j)=1$, you have nearest neighbor spatial autocorrelation. One can then handle $d(i,j)>1$ separately. With certain physical systems this seems like a simplistic but natural way of thinking about distance.

Does anyone know of a simple way to be able to calculate $d(i,j)$ as define here, without doing it manually?

DC PSA Map 2012

share|improve this question

migrated from Oct 17 '13 at 16:03

This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.

up vote 4 down vote accepted

This is typically described as contiguity based spatial weights, and is the most common type of spatial weights matrix used in spatial-lattice based regressions in the social sciences. Contiguity can typically be defined by either sharing an edge of the boundary (Rook), or touching somewhere at the edge of the boundary (Queen).

The weights file is frequently just stored just as list of neighbors, and in this case for regression models the weights are often (row) standardized to have nice interpretations or place bounds on the estimated auto-correlation for an endogenous model.

Other options are to use weights that vary with distance (frequently from the centroid if using lattice data) or use weights adjusted for the amount of the edge that are shared between neighboring polygons.

An open-source tool to compute spatial weights matrices is GeoDa. The GeoDa center also has a variety of tutorials on conducting spatial analysis that would be of interest.

share|improve this answer
Thanks Andy. Definitely preferable to simply laying out a fine grid of points based upon the range of the map, identifying which polygon each grid point is within, and then using the resulting matrix to construct the unique list of neighbors. – Dan Oct 17 '13 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.