Political piece is here. This post is under construction. I am using R to read ESRI shp with City, County, Precinct, CVAP (Census) data.
library(rgdal)
library(sp)
jpeg_create <- function() {
systime <- as.numeric(Sys.time())
# dev.new()
jpeg(filename = systime,
width = 1024, height = 768, units = "px", pointsize = 12,
quality = 100, bg = "white", res = NA, family = "", restoreConsole = TRUE,
type = c("windows"))
Sys.sleep(2)
}
setwd("C:/Politics/precinct2011shp")
WCshp <- readOGR("C:/Politics/precinct2011shp","precinct2011")
plot(WCshp,col="red")
setwd("C:/Politics/COB_plan_shps/COB_Shps")
COBshp <- readOGR("C:/Politics/COB_plan_shps/COB_Shps","COB_plan_Precincts")
plot(COBshp,col="blue")
setwd("C:/Politics/tl_2013_53_bg")
WA_shp <- readOGR("C:/Politics/tl_2013_53_bg","tl_2013_53_bg")
WC_CVAP_shp <- (subset(WA_shp, COUNTYFP == '073'))
plot(WC_CVAP_shp,col="yellow")
par(mfrow=c(1,3))
plot(WCshp,col="red")
plot(COBshp,col="blue")
plot(WC_CVAP_shp,col="yellow")
#
setwd("C:/Politics/CVAP_CSV_Format_2008-2012_ACS")
BlockGr <- read.csv("BlockGr_WA_Whatcom.csv", header = TRUE,stringsAsFactors = FALSE)
WA_CVAP <- sqldf("Select * from BlockGr where LNTITLE == 'Total'")
WA1_CVAP <- WA_CVAP[,c(1,5,6,7)]
arrange(WA_CVAP[,c(1,5,6,7)],desc(CVAP_EST))
setwd("C:/Politics/tl_2013_53_bg")
WA_shp <- readOGR("C:/Politics/tl_2013_53_bg","tl_2013_53_bg")
WC_shp <- (subset(WA_shp, COUNTYFP == '073'))
plot(WC_shp)
list1=WC_shp$GEOID
setwd("C:/Politics/CVAP_CSV_Format_2008-2012_ACS")
BlockGr <- read.csv("BlockGr_WA_Whatcom.csv", header = TRUE,stringsAsFactors = FALSE)
BlockGr1 <- (subset(BlockGr, LNTITLE == 'Total'))
BlockGr1$GEOID <- substring(BlockGr1$GEOID,8,19)
#for(i in list1){plot(subset(WC_shp,GEOID==i));mtext(subset(BlockGr1,GEOID==i,select=c(CVAP_EST)))}
WC_shpdf <- as.data.frame(subset(WA_shp, COUNTYFP == '073'))
WC_shpdf <- arrange(WC_shpdf,desc(GEOID))
BlockGr1df <- as.data.frame(BlockGr1df)
BlockGr1df <- arrange(BlockGr1df,desc(GEOID))
WC_shpdf <- arrange(WC_shpdf,desc(GEOID))
WC_Block <- cbind(BlockGr1df,WC_shpdf)
# colnames(WC_Block$GEOID) <- WC_Block$GEOID1
for(i in list1)
{plot(subset(WC_shp,GEOID==i))
mtext(subset(BlockGr1,GEOID==i,select=c(CVAP_EST)),line=2)
mtext(subset(BlockGr1,GEOID==i,select=c(CIT_EST)),line=1)
mtext(subset(BlockGr1,GEOID==i,select=GEOID),line=0)}
for(i in list1)
{jpeg_create()
plot(subset(WC_shp,GEOID==i))
mtext(subset(BlockGr1,GEOID==i,select=c(CVAP_EST)),line=2)
mtext(subset(BlockGr1,GEOID==i,select=c(CIT_EST)),line=1)
mtext(subset(BlockGr1,GEOID==i,select=GEOID),line=0)
graphics.off()
plot.new()}
No comments:
Post a Comment