3 回答

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊
在 SAS 中,使用GEODIST
函數(shù).
GEODIST 函數(shù)
返回兩個(gè)緯度和經(jīng)度坐標(biāo)之間的大地距離。
…
語法
GEODIST(latitude-1, longitude-1, latitude-2, longitude-2 <, options>)

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊
R解決方案
#sample data: first three rows of data provided
df <- data.frame( zip = c( "00501", "00544", "00601" ),
longitude = c( -73.045075, -73.045147, -66.750909 ),
latitude = c( 40.816799, 40.817225, 18.181189 ),
stringsAsFactors = FALSE )
library( sf )
#create a spatial data.frame
spdf <- st_as_sf( x = df,
coords = c( "longitude", "latitude"),
crs = "+proj=longlat +datum=WGS84" )
#create the distance matrix (in meters), round to 0 decimals
m <- round( st_distance( spdf ), digits = 0 )
#set row and column names of matrix
colnames( m ) <- df$zip
rownames( m ) <- df$zip
#show distance matrix in meters
m
# Units: m
# 00501 00544 00601
# 00501 0 48 2580481
# 00544 48 0 2580528
# 00601 2580481 2580528 0
添加回答
舉報(bào)