I'm having trouble with the areaPolygon function in R. Sometimes it appears to produce the correct result, and sometimes the results seem orders of magnitude off.
E.g. I have a polygon with these points:
lng <- c(-51.74768, -51.74768, -51.74735, -51.74735)
lat <- c(-0.1838690, -0.1840993, -0.1840984, -0.1838682)
and combine them into a dataframe
data <- data.frame(lng, lat)
Then I try to get the area:
area <- geosphere::areaPolygon(x = data)
which comes out to 326928.8 m^2.
I was expecting something more in the 1000 m^2 range.
What's weird is that this seems to work fairly well for about half the cells I'm calculating, but not the other half.
A similar StackOverflow question noted strangely small values, due to the points being in an incorrect order. However, when I plot, e.g.
plot(data, type="l")
The polygon seems to be drawing correctly.
Anyone know what might be wrong here? Thanks!
With your example data, result is as expected, as noted in the comments.
The idea that rounding plays a role seems far-fetched.