3

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

1 Answer 1

4

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 
WHERE p2.PK_UID=1 AND 
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?

2
  • 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
    Commented Aug 4, 2012 at 19:55
  • There's also this one: bostongis.com/…. 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
    Commented Aug 5, 2012 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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