3

enter image description here

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.

Taras
  • 32,823
  • 4
  • 66
  • 137
user144483
  • 59
  • 1

4 Answers4

4

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.

Micha
  • 15,555
  • 23
  • 29
3

Another approach is to use the "Extract by expression" tool with an expression that contains the overlay_touches() function:

overlay_touches(@layer)

Before:
input

After:
output

Taras
  • 32,823
  • 4
  • 66
  • 137
1

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:

  1. merge all the polylines that touch/intersect (let's say this wields merged_network) - see Join / merge lines that touch and intersect in QGIS
  2. from merged_network I would select the 'large' road network that I am interested in (merged_network_clear)
  3. using merged_network_clear I would select by location all the original polylines that intersect/touch it
vagvaf
  • 1,142
  • 1
  • 7
  • 16
1

An alternate method is to use the "Service area" tools in QGIS.

You can use this tool with a really long distance to find what is connected to the main network

Then use that to select the lines from the original layer and export them out

ScreenshotV2

Taras
  • 32,823
  • 4
  • 66
  • 137
Buff Fox
  • 119
  • 11