user3511534
user3511534

Reputation: 113

Determining the area of Shapefiles

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?

Upvotes: 5

Views: 5022

Answers (2)

FFI
FFI

Reputation: 402

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)

Upvotes: 2

Gary Weissman
Gary Weissman

Reputation: 3627

# 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

Upvotes: 8

Related Questions