I have a shapefile and I would like to find the polygon containing a list of points. For example,
rio <- readShapeSpatial("setores_rio.shp")
bairrorio.fort<- fortify(rio , region = "neighborhood")
head(bairrorio.fort)
long lat order hole piece group id
1 -43.17769 -22.91814 1 FALSE 1 330455705001.1 330455705001
2 -43.17771 -22.91814 2 FALSE 1 330455705001.1 330455705001
3 -43.17771 -22.91808 3 FALSE 1 330455705001.1 330455705001
4 -43.17793 -22.91811 4 FALSE 1 330455705001.1 330455705001
5 -43.17811 -22.91768 5 FALSE 1 330455705001.1 330455705001
6 -43.17802 -22.91766 6 FALSE 1 330455705001.1 330455705001
Assume that p = c(long, lat) is a point with lat long localization. I would like to find the id(neighborhood) (see bairrorio.fort) containing the point p.