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.

1
  • Did you use the tool: Vector> Sample> Spatial Sampling - Tick Include input layer objects related to selected objects? Jun 24, 2019 at 7:20

4 Answers 4

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.

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

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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.