Skip to content
Prev 5737 / 29559 Next

Calculating area of polygons

On Thu, 14 May 2009, Wesley Roberts wrote:

            
The areas are calculated when the Polygon objects are created - they are 
used internally for ordering the painting of the polygons, largest first):

library(rgdal)
scot_BNG <- readOGR(system.file("vectors", package = "rgdal")[1],
   "scot_BNG")
summary(scot_BNG)
getClass("Polygon")
areas <- sapply(slot(scot_BNG, "polygons"), function(x) sapply(slot(x,
  "Polygons"), slot, "area"))
str(areas)

areas is a list - each member is the vector of areas for rings belonging 
to the Polygons objects. You may also need to access the "hole" slot to 
see which "are" seen as holes for your data.

The areas are OK for planar coordinates, but only for these - for plotting 
the values, although not correct, are adequate for plot ordering.

Hope this helps,

Roger