# Triangle: London - New York - Rio de Janeiro
pts <- cbind(
lon = c(0, -74, -43),
lat = c(52, 41, -23)
)
polygon_area(pts)
# Multiple polygons using id
pts <- cbind(
lon = c(0, -74, -43, 100, 110, 105),
lat = c(52, 41, -23, 10, 10, 20)
)
polygon_area(pts, id = c(1, 1, 1, 2, 2, 2))
# Polyline length (not a closed polygon)
polygon_area(pts[1:3, ], polyline = TRUE)
# Area of Australia (approximate boundary)
australia <- cbind(
lon = c(113, 153, 153, 142, 129, 113),
lat = c(-26, -26, -10, -10, -15, -26)
)
result <- polygon_area(australia)
# Area in square kilometers
abs(result$area) / 1e6
Run the code above in your browser using DataLab