I am trying to calculate the area of a polygon defined in terms of latitude and longitude:
example_polygon <- data.frame(
lat = c(42.7093213,42.7079761,42.7093941,42.7080938,42.7093213),
lon = c(23.3194939,23.3194379,23.3194379,23.3182881,23.3194939)
) # last point equals first point
using the function areaPolygon
from the geosphere
package:
geosphere::areaPolygon(cbind(example_polygon$lon, example_polygon$lat))
[1] 350.9063
However, I have noticed that if I reorder the points in the polygon I get a different result:
example_scrambled <- example_polygon[c(2,1,3,4,2),]
geosphere::areaPolygon(cbind(example_scrambled$lon, example_scrambled$lat))
[1] 7780.469
My question is what is the reason for this disparity in the results (the function documentation does not mention that ordering matters)? Is there a correct way to order the points in a polygon, and what is it?