I have a dataset of roads in a city stored in a PostGIS enabled database. I would like to identify and remove any feature which is not connected to the rest of the road network. This behavior is common around the edges of networks, where the data was clipped.
I have found other answers on the GIS SE that do this, but they all appear to use ArcGIS, and I would like to solve the problem using PostGIS, QGIS, or a Python script.
My datasets can include over a million features, so performance is a concern.
Answer
I had a similar problem, so I developed a QGIS plugin which is now available in the official QGIS plugins repository and can be found in the QGIS menu: Plugins / Manage and Install Plugins... and search for Disconnected Islands.
http://plugins.qgis.org/plugins/disconnected-islands/
This plugin runs on a polyline layer, building up a road (or rail, etc.) network graph of connected links. It then analyses connected subgraphs, ones that are connected to each other, but not connected to isolated or floating links. It creates an additional attribute containing the group ID of the subgraph. This can then be used to style the layer with Categorised styles, or Zoom to selection. The disconnected links can then be fixed or removed.
Source code can be forked from: https://github.com/AfriGIS-South-Africa/disconnected-islands
My dataset has about 2 million links and it was analysed in less than 15 minutes, using 55 GB of RAM.

No comments:
Post a Comment