경도와 위도로 거리 계산하기
다음 소스 코드를 참고하세요.
suppressMessages({
if(!require(geosphere)) install.packages("geosphere")
library(geosphere)
})
korea<-data.frame(
longitude=c(126.956764,126.573234,126.542671),
latitude=c(37.540705,37.469221,33.364805),
city=c("Seoul","Incheon","Jeju")
)
mat_seoul<-distm(korea[,c('longitude','latitude')],korea[,c('longitude','latitude')],fun=distGeo)
mat_seoul/1000
suppressMessages({
if(!require(geosphere)) install.packages("geosphere")
library(geosphere)
})
korea<-data.frame(
longitude=c(126.956764,126.573234,126.542671),
latitude=c(37.540705,37.469221,33.364805),
city=c("Seoul","Incheon","Jeju")
)
mat_seoul<-distm(korea[,c('longitude','latitude')],korea[,c('longitude','latitude')],fun=distGeo)
mat_seoul/1000
댓글
댓글 쓰기