This question already has an answer here:
I have used the over function to retrieve the polygons of a map that contain points. I'am wondering, for my own learning purposes, if there is a way to use the over function to retrieve the polygons that don't have points in them. Is this possible?
Here is some code to return polygons of a map WITH points in them:
coordinates(data) <- ~ long_xcord + lat_ycord # Set the projection of the SpatialPointsDataFrame using the projection of the shapefile. proj4string(data) <- proj4string(shapeData) p <- over(data, shapeData, returnList = TRUE) p <- do.call(rbind.data.frame, p)
can the above be modified to return the polygons that DO NOT have points in them?