Computes the areas of regions in a projected map.

area.map(m, regions = ".", sqmi=TRUE, ...)

Author

Tom Minka

Arguments

m

a map object containing named polygons (created with fill = TRUE).

regions

a character vector naming one of more regions, as in map.

sqmi

If TRUE, measure area in square miles. Otherwise keep the units of m.

...

additional arguments to match.map

Details

The area of each matching region in the map is computed, and regions which match the same element of regions have their areas combined. Each region is assumed planar, with vertices specified by the x and y components of the map object.

The correct use of this function is to first use map to create polygons and project the coordinates onto a plane, then apply area.map to compute the area of the projected regions. If the projection is area-preserving (such as albers), then these areas will match the area on the globe, up to a constant. To get an absolute area in square miles, the sqmi option will scale the result, depending on the projection.

The coordinates from map are affected by its resolution argument, so use resolution=0 for the most accurate areas.

NOTE

The sqmi option assumes the coordinates have been projected with the mapproject function.

Value

a named vector of region areas.

See also

area.polygon, apply.polygon

Examples

# because the projection is rectangular, these are not true areas on the globe.
m = map("state", fill = TRUE, plot = FALSE)
area.map(m)
#> Warning: sq.mile correction unavailable for no projection
#>       . 
#> 816.295 
area.map(m, ".*dakota")
#> Warning: sq.mile correction unavailable for no projection
#> .*dakota 
#> 44.56549 
area.map(m, c("North Dakota", "South Dakota"))
#> Warning: sq.mile correction unavailable for no projection
#> North Dakota South Dakota 
#>     21.89865     22.66685 

if(require(mapproj)) {
  # true areas on the globe
  m = map("state", proj="bonne", param=45, fill=TRUE, plot=FALSE)
  # North Dakota is listed as 70,704 square miles
  area.map(m, "North Dakota")
}
#> Loading required package: mapproj
#> North Dakota 
#>     70962.81