Selects one or more CDP(s) from a given state

Share:

Description

city allows the user to pull out the polygon and metadata of one or more CDPs for any given state by name.

Usage

1
city(name, state, statefips = FALSE, sp.object = NULL, proj = NULL )

Arguments

name

a character string, takes the value of a string or string vector and has to be the exact name or names of CDP(s). (If you are unsure of the exact name a quick way to find it is to load the library(UScensus2000cdp) and pull out the list of names for the state you are interested in (see example).Note: if statefips=TRUE then this must be a CDP fips code.

state

a character string, can either be the full name (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.

statefips

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

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.

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(UScensus2000cdp)
##Load oregon.cdp data 
data(oregon.cdp)

##look at the list of oregon CDP names in alphabetic order
oregon.cdp$name[order(oregon.cdp$name)]

##grab the CDP of Portland, OR
portland<-city(name="portland",state="or")


##plot the polygon of Portland, OR
plot(portland)
title("Portland, OR")