poly.clipper: Selects the block, block group, or tracts which are contained...

Description Usage Arguments Value Warning Author(s) References See Also Examples

Description

poly.clipper allows the user to pull out all the blocks, block groups, or tracts that fall within the boundary of a given CDP and where the above grouping falls outside the boundaries poly.clipper will output the intersection of the two polygons and estimate the demographic variables based on the area of the intersection.

Usage

1
2
poly.clipper(name, state, statefips = FALSE, level = c("tract", "blk", "blkgrp")
, sp.object = NULL, proj = NULL) 

Arguments

name

a character string, this string must be the name of CDP for a given state (if statefips=TRUE then this must be a CDP fips code).

state

a character string, can either be the full name of a state (e.g. "oregon"), the abbreviation (e.g. "or"), or the FIPS code (e.g. "41")– note that if you are using the FIPS code you have to change statefips to TRUE. This variable is insensitive to case.

statefips

logical, by default statefips=FALSE, change to TRUE when providing state with a FIPS code.

level

character string, takes in one of three values: "tract", "blk", or "blkgrp". This defines the geographic level of data for the county.

sp.object

SpatialPolygonsDataFrame, default NULL, allows the user to provide an sp object in which to perform this operation; primarily for use with demographics.add.

proj

CRS-class, takes a CRS object (e.g. CRS("+proj=utm +zone=10 +datum=NAD83") ); This is simply a wrapper for the spTransform function in rgdal . WARNING requires rgdal package.

Value

An object of class SpatialPolygonsDataFrame.

Warning

You must have the packages UScensus2000blkgrp and UScensus2000blk installed to use levels "blkgrp" and "blk" respectively.

Author(s)

Zack W. Almquist almquist@uci.edu

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/.

Census 2000 Summary File 1 [name of state1 or United States]/prepared by the U.S. Census Bureau, 2001.
http://www.census.gov/prod/cen2000/doc/sf1.pdf

See Also

city

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
45
## Not run: 
##Perform the clipping
portland<-poly.clipper(name="Portland",state="OR",level="tract")

######Plot Portland as a Choropleth map

############################################
## 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=unique(ceiling(quantile(dem))),dig.lab = 6)
	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
############################################

colors.use<-color.map(portland,portland$pop2000)
plot(portland,col=colors.use$colors)
#text(coordinates(alabama.blk),alabama.blk@data$name,cex=.3)
title(main="Census Tracts of\n Portland Oregon, 2000", 
sub="Quantiles (equal frequency)")
legend("bottomright",legend=colors.use$dem.cut,
fill=colors.use$table.colors,bty="o",
title="Population Count",bg="white")


## End(Not run)

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