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

In a polygon layer, how can I generate a table of adjacent polygons?

share|improve this question
up vote 3 down vote accepted

What I would do is drop the polygon layer into Spatialite, then run a query like:

SELECT p1.PK_UID, p1.Name FROM Polys p1, Polys p2 
ST_Touches(p1.Geometry, p2.Geometry)=1;

I'm assuming a primary key column named 'pk_uid', and a label column called 'Name'. The above will return all polygons adjacent to (touching) the polygon with ID=1.

Is that what you had in mind?

share|improve this answer
It looks like this will work. Can you point me to a tutorial for Spatialite? I found one patterned after a cookbook with Italian data but I got terribly lost when I tried to follow the steps when it came to actually building a database. – HealthMaps Aug 4 '12 at 19:55
There's also this one:…. And you can always post on the spatialite-users maillist (in Google Groups). What do you mean by "building a database". In the gui you simple click on the "New Database" icon, and you're rady to go. THen click the "Load shapefile" to get shapefile based layers into the db. That's all there is to it. – Micha Aug 5 '12 at 8:06

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.