rise <- as.POSIXct("2011-03-03 06:49:00", tz="UTC") + 4*3600
set <- as.POSIXct("2011-03-03 18:04:00", tz="UTC") + 4*3600
mismatch <- function(latlon)
{
sunAngle(rise, latlon[1], latlon[2])$altitude^2 +
sunAngle(set, latlon[1], latlon[2])$altitude^2
}
result <- optim(c(1,1), mismatch)
lat.hfx <- 44.65
lon.hfx <- (-63.55274)
dist <- geodDist(result$par[1], result$par[2], lat.hfx, lon.hfx)
cat(sprintf("Infer Halifax latitude %.2f and longitude %.2f; distance mismatch %.0f km",
result$par[1], result$par[2], dist))
Run the code above in your browser using DataLab