# calculate distance between points crossing the antimeridian

How can I calculate the distance between two points (lon/lat) if any of the points exceeds the antimeridian (+-180 longitude)? Im using the `distVincentyEllipsoid {geosphere}` to calculate the shortest distance between two points. But if any of the points crosses the antimeridian the distance will be very close to zero. Is there a way to go about this problem? I have seen threads on similar problems but not using `R`.

Any pointers are highly appreciated, thanks!

• You do not seem to be asking about distance at all, but rather about computing reasonable bounding boxes (aka extents) of data. Is that the case? If so, your question may already have been answered at gis.stackexchange.com/questions/17788. If not, please edit your question to make clear what you would expect to see in an answer. – whuber Apr 9 '14 at 16:01
• Thanks for the comment. You're right, I was vague trying to squeeze in two different questions. I've updated it hopefully making it more focused. – jO. Apr 9 '14 at 16:19
• There are many threads on this site about calculating distances on spheres and ellipsoids: AFAIK, they all work fine for longitudes beyond the [-180, 180] interval because they all use the sines and cosines of the latitudes. On that basis I doubt `distVincentyEllipsoid` is incorrect. Could you perhaps supply an example of a pair of points with its output and what you think is the correct distance? – whuber Apr 9 '14 at 17:06
• simple workaround: shift all points in longitude so that your point of interest is at longitude 0. This will not modify the distances and none of the smallest distance will cross the antimeridian – radouxju Jul 1 at 12:05

``````library(geosphere)