How to clip out lat-long for individual participants to a corresponding area map in R?

Hello,

I have got about 20,000 lat-long data and a map with 6,000 polygons. Both datasets have no common identification variable and I need to overlay the 20,000 participants over the area map. And, then clip out each participant based on the area they fall and give the area polygon to run the statistical analysis I am looking forward.

I tried to do it in ArcMap; however, I found it very tedious and time-consuming. Is there any effective method to clip out and give a common identification variable (the area ID will be given to individual participants)?

Thanks

This is definitely possible using the sf package. In order for us to help you, could include some exmaple data as a minimal REPR oducible EX ample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help. See here for more info on making a reprex:

Additionally, I've written up an example of doing this point in polygon operation on my blog. See here for a walk-through of the process:

https://mattherman.info/blog/point-in-poly/

Hello,

I was trying to upload a map and lat-long data, but it couldn't allow me. It is saying "select images or files from your device (jpg, jpeg, png, gif, pdf)". The files I am uploading are map and csv files.

How do I upload the files?
Thanks

I think you might find this answer on "the other site" helpful, as I believe it describes your use case:

The key parts are:

  • import your data using {sf} package workflow
  • ensure the CRS of both data and polygons match (i.e. both are in lat-lon)
  • perform sf::st_intersection()
2 Likes

Many thanks. It works well.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.