5

I have a road network map which I need to cut off parts off using a polygon.

Both road network and the polygon are shapefiles. What I need to do is to use the polygon like a cookie cutter and cut off the road parts which fall into the polygon. After the operation is complete, what should be left is the road network which does not belong inside those polygons

So start:

enter image description here

Polygon:

enter image description here

Expected Result:

enter image description here

I tried to do this in QGIS using the Difference, intersection and other features in the Geoprocessing toolbox but they don't seem to work because I have two types of features. (Lines and Polygon)

I cant convert the road layer to polygon, that would end up in a disastrous mesh of polygons.

Is there a way to do this in QGIS? I am very new to QGIS, so assume a complete dummy.

6
  • This is definitely a job for difference. What exactly did you do when using this tool, and how did the result not satisfy you?
    – Erik
    Jul 15, 2020 at 8:28
  • Difference did nothing. Just the polygon was left after the job was finished. :( What I did was to select Vector > GeoProcessing Tools > Difference and selected the layers. Jul 15, 2020 at 8:31
  • 1
    Yeah, and you probably set the polygon first and the line layer second. Read the tooltip carefully and then reverse the layer order.
    – Erik
    Jul 15, 2020 at 8:32
  • @Erik holy cow. YES! That worked.!!! Please do post that as an answer. Jul 15, 2020 at 8:36
  • The layers are in the same coordinate system (epsg)?
    – pjhooker
    Jul 21, 2020 at 19:27

1 Answer 1

5

This task can be done using difference. Set the line layer first, the polygon second, then the polygon area will be substracted from the lines and you have your desired result.


A bit of genereal advice: If a tool "does nothing", there are several option. Maybe the tool really doesn't work, maybe your layers are faulty, or maybe the user did something wrong. It happens to everyone, and my first step when this happens to me, is to take a look at the tooltip. For every tool in the GUI there's a rather helpful tooltip to the right of the dialogue. E.g. for difference it says

This algorithm extracts features from the Input layer that don’t fall within the boundaries of the Difference layer. Input Layer Features that are partially within Difference layer feature(s) are split along the boundary of the clip layer feature(s). If any features are selected in the Input and Difference Layers, then only those features are used in the operation. If no features are selected, then the operation is performed using all features.

This states clearly, that areas of the second layer are substracted from the first one. So, if you put your lines as second layer, there's no area which could be substracted from the polygon.

Your Answer

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

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