Search code examples
rpandasbuffergeopandas

Points within buffer with the same id


I have a buffer layer and a point layer:

 buffer_gdf
     ID
0    1A
1    1B
2    1C

and

 point_gdf
      ID
0     1A
1     1A
2     1A
3     1A
4     1A
5     1B
6     1B
7     1B
8     1B
9     1B
10    1B
11    1B
12    1B
13    1B
14    1C    
15    1C
16    1C
17    1C    
18    1C
19    1C
20    1C    
21    1C
22    1C

Is there a way to count how many points with ID=1A are within buffer ID=1A, how many points ID=1B are within buffer ID=1B, how many points ID=1C are within buffer ID=1C, and so on... I have more than 20000 buffers and more than 300000 points.

I'm using pandas but I can also use R.

Sorry, I didn't mention that some points are outside the buffers. I just need those within the buffers


Solution

  • Thank you all so much for your help. However, the best and useful answer for me is this post.