8

I have a problem that is similar to Get Points in a selected polygon.

I have a polygon layer (with +200 features) that represents a road (subdivided by every 100m) and a point layer of a GPS survey driving through the road.

I want to clip all the points of a selected feature from the polygon layer. My problem is that I have +200 features and I need to do this to every feature.

Is there an easier way to do this than manually selecting 200 features individually and exporting the selection?

Taras
  • 32,823
  • 4
  • 66
  • 137
Bruno Farias
  • 91
  • 1
  • 4

3 Answers3

9

There is a direct and very easy way to do this. In the Clip tool, press the green cyclic arrows button next to the Overlay layer dropdown menu. That instructs to iterate the operation over the features of the layer.

You'll get seperate layers for each polygon.

enter image description here

For more details check the "Iterative execution of algorithms" article from the QGIS Training Manual.

Taras
  • 32,823
  • 4
  • 66
  • 137
Vajira
  • 91
  • 2
8

You can do this in two steps using QGIS.

(1) First, use the tool the "Join Attributes by Location" to create a new field in your points layer that describes which polygon each point falls into:

Join Attributes by Location

(2) Next, run the "Split Vector Layer" tool to write separate shapefiles for each unique value in the new field created by the previous step:

Split Vector Layer

Before: Before

After: After

Taras
  • 32,823
  • 4
  • 66
  • 137
Kartograaf
  • 2,902
  • 7
  • 23
2

You may also try the SAGA's "Clip Points with Polygons" module with ticked 'Iterate over this layer'.

window

Taras
  • 32,823
  • 4
  • 66
  • 137