0

I am trying to calculate the centroid of a dataframe containing the following long/lat data:

> test_points
     Lon    Lat
1  6.913 51.131
2  6.900 51.133
3  6.883 51.167
4  6.933 51.167
5  6.941 51.177
6  6.982 51.178
7  7.000 51.200
8  6.861 51.205
9  7.014 51.221
10 8.041 51.750
11 8.000 51.767
12 8.050 51.800

However when I apply the centroid function:

centroid(test_points)

I get the following result:

          lon      lat
[1,] 10.96005 53.32525

Does anybody have any idea where this goes wrong? Thanks in advance.

dumei
  • 47
  • 5
  • From which package does the `centroid` function come? Can you make this a reproducible example? – Matifou Nov 30 '21 at 14:18
  • the ```geosphere``` package – dumei Nov 30 '21 at 14:24
  • How exactly do a make this a reproducible example? I've given you all the information I use – dumei Nov 30 '21 at 14:25
  • centroid of point is point, what does your data represent? – det Nov 30 '21 at 14:28
  • Each row in the dataframe represents a geographical point in Germany. I want to calculate the center of these 11 places, however, the centroid function, which has yielded right answers before, yields a clearly wrong answer here. My question is: what goes wrong? – dumei Nov 30 '21 at 15:15
  • See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and https://reprex.tidyverse.org/ on how to make example reproducible. Problem here is that you did not provide data in a way people can easily use in their R session – Matifou Nov 30 '21 at 17:14

0 Answers0