I have a topographic map in raster file and I want to add the lines for fault systems on top (in shapefile), but I want to crop them so I'm only left with those that are within the raster image.

Is there a way to use the raster to select the shapefile that are within the boundaries of the raster file?

I'm using QGIS 2.10.1.

enter image description here

  • 2
    This is very interesting question to me, too... Just in case if you need to get this done immediately, a readily available tool would be Vector | Geoprocessing Tools | Clip. But this requires a polygon to clip. There will be options to obtain such polygon: (AA) Assuming your area is close to coastline, download a coastline polygon from somewhere, and modify it to fit your need. (BB) Manually digitize a polygon along the edge of your raster file. (CC) Use Polygonizer (Raster | Conversion | Polygonize) tool. I think (AA) is the easiest, while (CC) requires many steps to get usable polygon. – Kazuhito Nov 27 '16 at 4:01

This is easier than it seems:

Raster -> Conversions -> Polygonize
Vector -> Geoprocessing Tools -> Clip

Depending on your raster file format, the options to polygonize are different, but commonly you choose "DN" as attribute. And if your raster has a proper mask layer (or NaN values), you can select that so these are omitted, too!

Et voilà, you get a simple vector file that traces the outline of your raster.

Then, use the Clip tool: Choose the fault polyline layer as input, and the polygonized raster layer as Clip layer.

Keep in mind that the polygonized raster will never be a perfect fit to the raster file. So depending on your use case, you might want to manipulate it (buffer +-) to ensure no polylines are cut off too short.

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.