hypertidy/geodist

Fix cheapdist

mpadge opened this issue · 2 comments

@mdsumner This one's for you, also to help you get your teeth into the code. I've implemented Haversine, Vincenty, and the mapbox cheap ruler, but the latter does not give consistent results:

n <- 50
dx <- dy <- 0.01
x <- cbind (-100 + dx * runif (n), 20 + dy * runif (n))
y <- cbind (-100 + dx * runif (2 * n), 20 + dy * runif (2 * n))
colnames (x) <- colnames (y) <- c ("x", "y")
d1 <- geodist (x, measure = "haversine")
d2 <- geodist (x, measure = "cheap")
plot (d1, d2, pch = 1)

junk

I think part of the problem is that the notes in their blog description purport to calculate cos((lat1 + lat2) / 2 as if these are in degrees rather than radians. I've converted them to radians, but have not converted other values. These kind of inconsistencies are the likely cause, and likely all that need be done is to look inside the cheap rule source code and fix my coded interpretation of the blog accordingly.

Looking awesome, just hit Thailand so will be a few weeks at least!

oh cool - enjoy that break! there's no hurry on this, i just used it as a chance to up my R-C skillz! have fun, and let me know if you might have time anywhere in the vicinity