R geosphere package: unit of distance

Hello dear forum members,

I have the following question in relationship to R geosphere package:

So, as per package description (ftp://cran.r-project.org/pub/R/web/packages/geosphere/geosphere.pdf, page 3) — "The default unit of distance is meter; but this can be adjusted by supplying a different radius r to functions.” My understanding here is that for meters (by default) the Earth radius used is in kilometers — 6371. Now, if I use a different radius — say in miles (3956) — what will be the unit of distance in such case? E.g., foot, yard, or may be some fraction of a mile?

Thank you in advance for help with this question.


Probably A Mammal
Looking at the documentation, the default r value in the first function (alongTrackDistance) is 6378137, representing exactly as you indicated: Earth radius is 6371 km. If you want it in miles, then r = 3956 would put everything in terms of miles. If you used 20.9 million, then you would get calculations in feet.

In other words, whatever value you put in for r should reflect what the measure of Earth's radius is to your calculations. You could put r = 1000, then it wouldn't really align to anything in reality, but the results you get would be in terms of this arbitrary unit of measure indexed to Earth radius being 1,000. At least that's my understanding of the r parameter.

Though, while that aids flexibility, I don't know why they didn't just give a list of options like (km, m, mi, ft, etc.) and do the number assignment internally, with an optional NULL parameter r that lets you put in your own basis, but that's a feature somebody could take to the maintainer of the package.