I have a shapefile consisting of polylines. I have managed to explode these polylines (break at there vertices). There are a bunch of lines all over the shapefile which are not connected (shown in the red boxes). Is there a way to delete them automatically. What I mean is not selecting them individually because its difficult to manually locate each and every line which isn't connected.
If you're willing to use GRASS, you can do this with the
v.clean module, choosing the
rmdangle tool, and a suitable threshold.
# STart GRASS using your polyline shapefile (to determine the coordinate system for a new location) grass -c polyline.shp YourPathToGISDBASE/YourLocation/YourMapset # Import the shapefile v.import polyline.shp output=polylines # And do the remove dangles operation v.clean polylines tool=rmdangle thresh=xxxx output=polylines2
The xxxx value is some length that makes sense in your situation: larger than the length of the dangles. You might want to run several times, each time with a slightly larger threshold value, until you find what works.
I understand that you have a large road network that you are interested in and would like to discard the 'small networks' that consist of fewer number of links (like the one on the top right).
I would approach the problem like this:
- merge all the polylines that touch/intersect (let's say this wields merged_network) - see Join / merge lines that touch and intersect in QGIS
- from merged_network I would select the 'large' road network that I am interested in (merged_network_clear)
- using merged_network_clear I would select by location all the original polylines that intersect/touch it