Euclidean distance between climatic data of two points

Hi! I am working with climatic data of several plant species. I have created a hypervolume and obtained its centroid, and now I am trying to calculate the Euclidean distance between it and another centroid. I have been trying using the pointDistance command like this, but get an error:

pointDistance(unscaledCentroid_Celtisaustralis, hoh.clim,lonlat=FALSE, allpairs=FALSE)
Error in .pointsToMatrix(p1) : Wrong length for a vector, should be 2

I have checked the data in both points but I can't see anything that could explain this error.


A tibble: 1 × 6

species point_ID mean_temperature mean_precipitation seasonality_temperature seasonality_precipitation

1 Uni Hohenheim centroid 9.04 70.8 666. 0.476

mean_temperature mean_precipitation seasonality_temperature seasonality_precipitation
12.6879987 85.7007952 0.6085140 0.7323761

Does anyone know what I am doing wrong? Thank you.

pointDistance is planar and so only takes two input vectors. For n-space, a matrix and base::dist is available

x <- matrix(c(9.04,70.8,666.,0.476,12.6879987,85.7007952,0.6085140,0.7323761), ncol = 2)

(d <- dist(x))
#>           1         2         3
#> 2  95.63036                    
#> 3 657.07104 601.25181          
#> 4  14.70643 110.29550 665.52401

Understood. Thank you very much for the quick answer!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.