在R中使用geosphere包时,维数不正确

时间:2017-01-15 19:59:12

标签: r geospatial geosphere

尝试计算两个数据集中纬度/经度点之间的距离矩阵.... 这是我的R脚本代码,然后是错误消息。关于我哪里出错的任何想法?

> library(geosphere)
## step 1: open 2000 data for birds and air temp
> birds<-read.table(file.choose(),header=T,sep="\t")
> birds
> temp<-read.table(file.choose(),header=T,sep="\t")
> temp

##step 2: calculate the distance matrix D, which is the distance between lat/long points in your two datasets

> D = distm (birds<- 3:2, temp<- 2:1)
> new_birds =cbind(birds, temp[apply(D , 1 , which.min),])
  

临时错误[apply(D,1,which.min),]:错误的数字   尺寸

0 个答案:

没有答案