I'm using gDistance
from the rgeos
package for R to find the nearest point to a polygon. The projection of both points and the polygon is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
. My code looks something like this:
min(gDistance(MyPolygon, MyPoints, byid=TRUE))
Running this gives a result and the following warnings:
Warning messages:
1: In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance") :
Spatial object 1 is not projected; GEOS expects planar coordinates
2: In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance") :
Spatial object 2 is not projected; GEOS expects planar coordinates
My understanding of this is that gDistance
isn't happy with my projection (or lack thereof). The actual magnitude of the result isn't important, just that the point is indeed the closest point to the polygon. My question is will this result change if I change the projection? That is, regardless of the actual numeric value of the distance between the polygon and point, will the same point be identified as being closest if I changed the projection?
Further details
My points are data that has a global coverage over the oceans at a 1 degree resolution. My polygons are regions of the ocean typically a few degrees in length, but generally quite narrow. Nevertheless, since the points and polygons originate from different sources, the two do not necessarily line up – which is why I need to find points closest to the polygons. That said, there will always be a point within 1 degree of a polygon. My results don't need to be very accurate (i.e., ballpark estimates).
No comments:
Post a Comment