2
ただ、次の例チェックアウト:それはようで私になぜ地理的距離が間違っているのですか?
lat <- c(47.5, 47.5, 47.501)
lng <- c(9.3, 9.301, 9.3)
geosphere::distVincentyEllipsoid(lng[c(1,2)], lat[c(1,2)])
# [1] 5551424 Should be about 5000 m?
geosphere::distVincentyEllipsoid(lng[c(1,3)], lat[c(1,3)])
#[1] 5551583 Should be about 5000 m?
m <- leaflet() %>%
addTiles(group = "OSM") %>%
addProviderTiles("Stamen.TonerLite") %>%
addLayersControl(
baseGroups = c("OSM", "Stamen.TonerLite")) %>%
addCircleMarkers(lat = lat,
lng = lng,
color = "blue",
stroke = FALSE,
radius = 3,
fillOpacity = 0.7)
print(m)
を、結果はかなりものの????distVincentyEllipsoid
オフの状態である:楕円体と同じ単位で
距離値(デフォルトはメートル)
編集:
:ちょうど hereからの単純なクロスチェックなどR = 6371 # radius of the earth in km
x = (lng[2] - lng[1]) * cos(0.5*(lat[2]+lat[1]))
y = lat[2] - lat[1]
d = R * sqrt(x*x + y*y) # in km