QGIS Vector Data – Removing Part of the Polygon Outside Another Shapefile While Keeping Overlapping Parts

qgisvector

I have two shape files: one for the African continent, and another with cells covering the continent. However, since the cells are an arbitrary constructions, some of cells even if they are overlapping the continent, they have some part outside of it. In other words, there are some cells which have some part within the continent and another part outside the continent. Is it possible to remove the part outside of the continent?

I tried with select by location, disjoint option, and after remove the cells using toogle editing. However, this option is not working because all my cells are touching the continent as a polygon.

Please, if you do not understand the problem, ask me to clarify. I attach a picture to make it clear.

enter image description here

[EDIT:]

The solution of Vincé and TeddyTedTed works perfectly. However, when I do it, some borders of my map of Africa disappear or they appears with a several discontinuities. Is there any solution to this? I attach a picture to make clear the problem. Additionally, When I select some of the cells (with identify features), the discontinuities appears as a part of the cell.

enter image description here

Best Answer

You will need to create a new version of the layer containing only the cells within and the overlapping parts of the cells along the edges.

This can quickly be achieved by using the clip tool. Have a look at this link from the user manual. Here's also a 1:45 min short video explaining it.

Your input layer: the grid (in the below image represented by the RED circle)

Your mask layer: the outline of Africa (in the below image represented by the GREEN circle)

enter image description here *source: https://docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/vectoroverlay.html?highlight=clip#clip