I am trying to find the shortest distance from a point to a polygon. I have a point on the shoreline of a map I made and I need the distance from this point to a polygon outside the shoreline. The polygon is an irregular shape (contaminant location on the surface of the water on a particular day). Both the point and the polygon are in longitude/latitude coordinates, and I can overlay the polygon onto the map. I tried to use (geosphere package)
dist2Line(-88.1253, 30.2564, may.17.10A, distfun=distHaversine)
but I get an error message that says 'Error in dist2Line(-88.1253, 30.2564, may.17.10A, distfun = distHaversine) : unused argument (may.17.10A)'
I tried to add brackets around the point coordinates but got another error message. The coordinates for the point on the shoreline are -88.1253, 30.2564 and the polygon is may.17.10A. The function states that I can use a SpatialPolygons* object as a variable and I thought
may.17.10A
would be one?
The code for the polygon is from a directory with .dbf, .prj, .sbn, .sbx, .sph, and .shx files:
may.17.10 <- readOGR("directory/20100517_Composite", "20100517_Composite")
may.17.10A<- spTransform(may.17.10, CRS("+proj=longlat +datum=WGS84"))
As I have mentioned in my previous questions I am new to R and have no prior coding experience so I very much appreciate any help I can get. Thank you for any advice!