Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am looking for a functionality in QGIS to find all neigbours for each polygon in a polygon layer. The result should be a table with 2 ID-Columns: one for the polygon and the second for the neighbours.

I tried "spatial query" in QGIS with the layer as source and its copy as reference, but to no avail.

In Mapbasic of Mapinfo it would be a simple expression:

select t1.id1, t2.id2 from t1, t2 where t1.obj intersects t2.obj 

(where t1 and t2 are two copies of the polygon layer).

Thanks for any help!

share|improve this question
    
What type of topology? –  Willy Aug 26 '12 at 10:56

2 Answers 2

  1. Use vector tools (Vector -> Geometry tools -> Polygon centroids) to create a centroid layer of the polygons with IDs the same as the polygons
  2. Convert that layer into PostGIS (if possible)
  3. Use Regina's or Mackerron's implementations of nearest neighbour. You might have to do some sql modifications to be able to output an OD matrix.

Note: I will try and work on this and get an updated answer tomorrow with a lot more details and an example

share|improve this answer
1  
Spatialite would be a nice quick solution rather then using PostGIS –  Nathan W Aug 26 '12 at 11:35
1  
@NathanW good point. I've never used spatialite. Feel free to edit or repost an answer using it and i'll delete my answer after that. –  dassouki Aug 26 '12 at 12:03
    
How about this: gis.stackexchange.com/questions/30011/… –  Micha Aug 27 '12 at 5:47

thanks a lot for your advice.

Meanwhile I came up with another solution: 1) create a tiny buffer for each object in one layer; 2) use Geoprocessing Tools > Intersect it with another copy - and here you are.

Not that simple as in MapInfo and a bit unreliable (there is a small probability that a buffer will touch a polygon, which is not a neighbour, but which is separated from the source one by a vary tiny strip that is smaller than the buffer).

share|improve this answer

Your Answer

 
discard

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.