Consider the following scenario:
- I have made polygon of mainland Africa + Madagascar.
- From a different source I have got some point data about this area.
- The point data include points in small islands that I want to discard. So I use
over()in the R-package
spto filter out such points.
- However, hundreds of points at the coastline is slightly off my polygon(s), so they would also be discarded.
In the image below, only the points that are off are plotted.
I think that if I could only enlarge the two polygons (mainland Africa + Madagascar) slightly, then I could filter out points using
over(). Perhaps there is another solution that gives the same result, and if so that is great.
EDIT: using rgeos::gBuffer() as suggested by @mdsumner, the problem is now solved, which can be seen in this graph, where the points the are truly off mainland Africa and Madagascar are colored red and the points that where "false positives" are colored black.
The code used to enlarge the polygon(s) was:
Africa.2 <- spTransform(x=Africa, CRSobj=CRS("+init=epsg:32662")) library(rgeos) Africa.larger <- gBuffer(Africa.2, width = 50000)