撒科打诨
R解决方案#sample data: first three rows of data provideddf <- 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.framespdf <- st_as_sf( x = df, coords = c( "longitude", "latitude"), crs = "+proj=longlat +datum=WGS84" )#create the distance matrix (in meters), round to 0 decimalsm <- round( st_distance( spdf ), digits = 0 )#set row and column names of matrixcolnames( m ) <- df$ziprownames( m ) <- df$zip#show distance matrix in metersm # Units: m# 00501 00544 00601# 00501 0 48 2580481# 00544 48 0 2580528# 00601 2580481 2580528 0