From this Question I obtained the great function areaPolygon()
which gives me the area within a polygon of coordinates. however, when I experiment with the func
You've made an invalid polygon! If you plot it with type="l"
you'll see a bow-tie:
> plot(polygon,type="l")
Half the bow-tie will have a negative area, the other half positive, so your result is the difference in the sizes of the halves. They won't be exactly the same because of the earth being spherical...
You just need to reorder your points in polygon
.