Last active
October 8, 2015 13:06
-
-
Save AndrewTheTM/39fec66e5f7f3cb5872b to your computer and use it in GitHub Desktop.
R+OMX County Flow
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
modelPath = "C:\\Modelrun\\Model80\\Base\\" | |
source("http://raw.githubusercontent.com/osPlanning/omx/dev/api/r/omx.R") | |
ZtoC = A1201[,c("TAZ","COUNTY")] # This is the TAZ-County equivalence table | |
hbwpk = readMatrixOMX(paste(modelPath,"HBWPK.OMX",sep=""),"M1") | |
cnames = rbind('HAMILTO', 'CLERMON', 'BUTLER', 'WARREN', 'BOONE', 'CAMPBEL', 'KENTON', 'DEARBOR') #could probably also do rbind(unique(ZtoC$COUNTY)) | |
hbwpk.cf = matrix(0,length(cnames),length(cnames)) | |
for(ic in 1:length(cnames)){ | |
for(jc in 1:length(cnames)){ | |
hbwpk.cf[ic,jc] = sum(hbwpk[which(seq(1:nrow(hbwpk)) %in% ZtoC[which(ZtoC$COUNTY == cnames[ic]),"TAZ"]), | |
which(seq(1:ncol(hbwpk)) %in% ZtoC[which(ZtoC$COUNTY == cnames[jc]),"TAZ"])]) | |
} | |
} | |
# Optional | |
rownames(hbwpk.cf) = cnames | |
colnames(hbwpk.cf) = cnames |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment