I have a point's coordinates as well as an object with the class of sfc_polygon in R. I would like to check if this point lies inside that polygon or not.
I created an object with the class of sfc_point by applying st_point() function on the point's coordinates and I used the st_intersects function to check what I mentioned above. The code is as follows:
pnts = st_sfc(st_point(c(long,lat)), crs = 3006) iso = ABC$geom
(lst1 = st_intersects(pnts, iso)) (mat1 = st_intersects(pnts, iso, sparse = FALSE))
which points fall inside a polygon?
apply(mat1, 1, any) lengths(lst1) > 0
I plot the polygon and the point and I am sure that the point lies inside the polygon, but the result of the code above is false!
What is the problem with the code?