# areaPoly: Area of the polygons in SpatialPolygonsDataFrame In UScensus2000: US Census 2000 Suite of R Packages

## Description

Calculates the area of each polygon in `SpatialPolygonsDataFrame`.

## Usage

 `1` ```areaPoly(sp.object=NULL) ```

## Arguments

 `sp.object` `SpatialPolygonsDataFrame`, must be a `SpatialPolygonsDataFrame` object.

## Value

a numeric vector.

Zack W. Almquist

## References

Zack W. Almquist (2010). US Census Spatial and Demographic Data in R: The UScensus2000 Suite of Packages. Journal of Statistical Software, 37(6), 1-31. http://www.jstatsoft.org/v37/i06/.

Also see: SpatialPolygonsDataFrame

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44``` ```############################################ ## Helper function for handling coloring of the map ############################################ color.map<- function(x,dem,y=NULL){ l.poly<-length(x@polygons) dem.num<- cut(dem,breaks=ceiling(quantile(dem)),dig.lab = 10) dem.num[which(is.na(dem.num)==TRUE)]<-levels(dem.num)[1] l.uc<-length(table(dem.num)) if(is.null(y)){ ##commented out, but creates different color schemes ## using runif, may take a couple times to get a good color scheme. ##col.heat<-rgb( runif(l.uc,0,1), runif(l.uc,0,1) , runif(l.uc,0,1) ) col.heat<-heat.colors(16)[c(14,8,4,1)] ##fixed set of four colors }else{ col.heat<-y } dem.col<-cbind(col.heat,names(table(dem.num))) colors.dem<-vector(length=l.poly) for(i in 1:l.uc){ colors.dem[which(dem.num==dem.col[i,2])]<-dem.col[i,1] } out<-list(colors=colors.dem,dem.cut=dem.col[,2],table.colors=dem.col[,1]) return(out) } ############################################ ## Helper function for handling coloring of the map ############################################ library(UScensus2000tract) data(oregon.tract) ## Build density using areaPoly() den00<-oregon.tract\$pop2000/areaPoly(oregon.tract) oregon.tract\$den00<-den00 colors.use<-color.map(oregon.tract,oregon.tract\$den00) plot(oregon.tract,col=colors.use\$colors,border="transparent") title(main="Census Tracts \n of Oregon, 2000", sub="Quantiles (equal frequency)") legend("bottomright",legend=colors.use\$dem.cut, fill=colors.use\$table.colors,bty="o", title="Population Density",bg="white") ```

UScensus2000 documentation built on May 2, 2019, 5:13 p.m.