Assign polygon to data point in R dataframe
问题 I have a two data frames: points contains a series of points with x, y coordinates. poly contains coordinates of two polygons (I have over 100 in reality, but keeping it simple here). I want to be able to add to the dataframe points an extra column called Area which contains the name of the polygon the point is in. poly <- data.frame( pol= c("P1", "P1","P1","P1","P1","P2","P2","P2","P2", "P2"), x=c(4360, 7273, 7759, 4440, 4360, 8720,11959, 11440,8200, 8720), y=c(1009, 9900,28559,28430,1009