Clipping line layer based on polygons with QGIS?
Use the Vector -> Geoprocessing -> Clip
tool
Input is your roads layer, clip layer is the polygon layer.
Put the line's layer in "input vector layer" and the polygon's layer in "Clip layer"
This gave me endless hours of frustration, and the above answers (even the ones in the comments) didn't work for me either, but I found my own solution that did the trick.
It turns out that to do an intersection or a clip between two layers, they must be saved on disk with the same CRS. So even if they look like they overlap in QGIS, it may be doing it's own "On the Fly" transformation to align them.
To fix this, do this for each layer:
- Right click, Save as...
- Set the format to ESRI Shapefile, pick a file name, and pick a CRS that you will use for all the layers. Click OK to save, and load that file.
- Repeat for the other layer, selecting the same CRS.
- Use the clip tool with the new layers. This should do the trick.
If you want to see if the 'On the Fly' transformation is what's causing you trouble, do this:
- Go to the Project menu, and click Project properties...
- Go to the CRS tab
- Uncheck Enable 'on the fly' CRS transformation and click Apply, OK
If your CRS's weren't the same, the layers should no longer overlap. You can see the position of either layer by right-clicking the layer and going to Zoom to Layer. When you load the two files with identical CRS, they should align perfectly.
Use the intersect feature. Vector > Geoprocessing Tools > Intersect.
- Input layer is your line
- Intersect layer is your polygon
- browse a document folder and save (preferred filename) in the Output Shapefile.