I am trying to check if location point is inside the polygon and it works for certain location point. But for certain location point output says point is outside polygon even if it is inside.
Rmap <- readShapePoly('MAP.shp')#rome shape file
mappoints <- fortify(Rmap)
data_raw<-data.frame(Longitude=12.477,Latitude=41.91020)
ind<-point.in.polygon( data_raw$Longitude, data_raw$Latitude, mappoints$long, mappoints$lat)
ggplot(mappoints) + aes(long, lat) + geom_polygon(fill="grey80",aes (group=group)) + scale_fill_manual(values = pretty_palette)+ geom_point(data=data_raw,aes(x=Longitude,y=Latitude))
Output: ind is always 0 which means point is outside polygon. Original plot is

overwithspclass objects and save the pointless (no pun intended)fortifystep? – Spacedman Apr 09 '18 at 14:57