I am using Postgres 9.5 and PostGIS. I have a table with a geometry field. This table has about 200 rows, in each of which the geometry field contains a Polygon.

I would now like to derive an undirected network graph from these rows, in which row is a node, and there is an edge between them if they share a boundary.

Is it possible to derive this somehow?

I also have the data in KML form, if that helps, and I think NetworkX can accept shapefiles.

  • Here's a start: SELECT a.code, b.code FROM frontend_pct a, frontend_pct b WHERE a.code != b.code AND ST_Distance(a.geometry, b.geometry) < 0.1; gets me a pairwise list of all polygons that border each other. (I think. 0.1 was chosen fairly arbitrarily and I'm not sure what units it's in.) – Richard Feb 11 '16 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.