Description Usage Arguments Value Examples
Returns a list of the areas of all the Polygon
objects of the polygons
slot of a SpatialPolygon*
object.
1 | areas(sppoly)
|
sppoly |
|
A list of same length as the input SpatialPolygon*
object. Each slot of the list is a numeric vector, the lenght of which is
equal to the number of Polygon
objects constituing the polygon entity.
Each of these values are the areas of the of the Polygon
objects,
expressed in the unit of the CRS.
1 2 3 4 5 6 7 8 9 10 11 12 | library(sf)
# working on the provinces polygons of Vietnam:
vn_prov <- gadmVN::gadm()
vn_prov <- sf::as_Spatial(vn_prov)
poly_areas <- areas(vn_prov)
# we can see that some of the polygons are made of several polygons:
sapply(poly_areas, length)
# we can verify that it sums well for the whole country
rgeos::gArea(vn_prov)
sum(sapply(poly_areas, sum))
# as well as for each province:
cbind(rgeos::gArea(vn_prov, TRUE), sapply(poly_areas, sum))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.