How can one determine the area of a shapefile?
When I use summary(data)
, it gives the area, but then I have no idea what the area of each shapefile polygons are.
Also, can the area be converted to meters?
# load the rgeos library
library(rgeos)
# make a polygon (borrowed from ref manual for package)
sample_poly <- readWKT("POLYGON((0 1,0.95 0.31,0.59 -0.81,-0.59 -0.81,-0.95 0.31,0 1))")
# and calculate the area
gArea(sample_poly)
[1] 2.3803
data@polygons[[1]]@Polygons[[1]]@area
data@polygons[[2]]@Polygons[[1]]@area
Will give you areas of the first and second polygons, you can figue a for loop to give you all or show us the names with:
names(data)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With