Created
January 13, 2014 19:34
-
-
Save justgrimes/8406507 to your computer and use it in GitHub Desktop.
Downloads FY 2011 Public Library Survey data files from Institute of Museum and Library Services website and constructs a small multiple map of NCES locale codes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load packages | |
library(maps) # To draw map | |
library(maptools) | |
# download data files from IMLS website | |
temp <- tempfile() | |
download.file("http://www.imls.gov/assets/1/AssetManager/pupld11b_csv.zip",temp) | |
pupld11b <- read.csv(unz(temp, "pupld11b.csv")) #file with library systems (admin buildings) | |
puout11b <- read.csv(unz(temp, "puout11b.csv")) #file with library outlets (all buildings) | |
unlink(temp) | |
#remove Alaska and Hawaii from contigous map | |
PA <- pupld11b[pupld11b$STABR!= "AK", ] | |
PA <- PA[PA$STABR!= "HI", ] | |
PO <- puout11b[puout11b$STABR!= "AK", ] | |
PO <- PO[PO$STABR!= "HI", ] | |
# split outlet file by locales | |
POL1 <- PO[PO$LOCALE == 11 | PO$LOCALE == 12 | PO$LOCALE == 13, ] | |
POL2 <- PO[PO$LOCALE == 21 | PO$LOCALE == 22 | PO$LOCALE == 23, ] | |
POL3 <- PO[PO$LOCALE == 31 | PO$LOCALE == 32 | PO$LOCALE == 33, ] | |
POL4 <- PO[PO$LOCALE == 41 | PO$LOCALE == 42 | PO$LOCALE == 43, ] | |
POL11 <- PO[PO$LOCALE == 11, ] | |
POL12 <- PO[PO$LOCALE == 12, ] | |
POL13 <- PO[PO$LOCALE == 13, ] | |
POL21 <- PO[PO$LOCALE == 21, ] | |
POL22 <- PO[PO$LOCALE == 22, ] | |
POL23 <- PO[PO$LOCALE == 23, ] | |
POL31 <- PO[PO$LOCALE == 31, ] | |
POL32 <- PO[PO$LOCALE == 32, ] | |
POL33 <- PO[PO$LOCALE == 33, ] | |
POL41 <- PO[PO$LOCALE == 41, ] | |
POL42 <- PO[PO$LOCALE == 42, ] | |
POL43 <- PO[PO$LOCALE == 43, ] | |
#construct 4x4 grid of outlets by locale | |
par(mfrow=c(4,4),mar=c(0.75,0.75,0.75,0.75)) | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL1$LONGITUD, POL1$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("City") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL11$LONGITUD, POL11$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("City - Large") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL12$LONGITUD, POL12$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("City - Midsize") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL13$LONGITUD, POL13$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("City - Small") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL2$LONGITUD, POL2$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Suburb") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL21$LONGITUD, POL21$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Suburb - Large") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL22$LONGITUD, POL22$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Suburb - Midsize") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL23$LONGITUD, POL23$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Suburb - Small") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL3$LONGITUD, POL3$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Town") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL31$LONGITUD, POL31$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Town - Fringe") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL32$LONGITUD, POL32$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Town - Distant") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL33$LONGITUD, POL33$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Town - Remote") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL4$LONGITUD, POL4$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Rural") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL41$LONGITUD, POL41$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Rural - Fringe") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL42$LONGITUD, POL42$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Rural - Distant") | |
map("state", proj="albers", param=c(39,45), lwd=1, col="#cccccc") | |
points(mapproject(POL43$LONGITUD, POL43$LATITUDE), | |
col=NA, bg="#000000", pch=21, cex=0.20) | |
title("Rural - Remote") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment