Skip to content

Assessing Local Land Use Growth Patterns

Alex Bettinardi edited this page Aug 25, 2017 · 2 revisions

Background and Purpose

Typically when pulling future information (like volumes / trip patterns) from SWIM, it is important to first understand what is happening in the area of interest from a population (housing) and employment growth stand point. Meaning that how SWIM is growing the area is directly related to how the travel patterns are growing. Therefore, a good first step in providing future information for a focused area will always be pulling and understanding the population and employment growth in that area.

Given SWIM's hundreds of files and ~30 years worth of data output folders, this can be an overwhelming thought at first. However, SWIM's database makes this effort relatively painless and below on this page some R functions / examples are provided to help make this a very easy effort.

Example script

First a user needs to point to and then gain access to the SWIM database, here is an example of that (note the RSQLite library is requred):

# define scenarios to be pulled
dbs <- c("M:/swim2/Reference/outputs/Reference.db")
names(dbs) <- c("Reference")

# setup connection to SQLite
library(RSQLite)
m = dbDriver("SQLite")

Then the user can pull the alphazone level detail from the "AZONE" table in the database:

   # connect to the database
   DB = dbConnect(m, dbs)
   # Pull link data
   azone = dbGetQuery(DB, "SELECT * FROM AZONE")
   azone$TSTEP <- as.numeric(azone$TSTEP)+1990

Typically the user might also want to pull alphazone and beta zone attribute fields to help tabulate the data as well:

   aFields <-  dbGetQuery(DB, "SELECT * FROM ALLZONES") 

Here is a function that has been developed to sum up population and employment for multiple zones into a "region" (rg) summary for those zones (a single population and employment number for each year for the group of zones):

# define regional summary function
rgPopEmp <- function(zns){
   zn.. <- azone[as.character(azone$AZONE) %in% zns,c("AZONE","POPULATION","EMPLOYMENT","TSTEP")]
   cbind(POP=tapply(zn..$POPULATION, zn..$TSTEP,sum, na.rm=T),EMP=tapply(zn..$EMPLOYMENT, zn..$TSTEP,sum,na.rm=T))
}  

Put it all together here is an example where multiple regions in an area (in this example groups of zones and also surrounding counties) can be quickly plotted into a pdf to be viewed and shared:

# define scenarios to be pulled
dbs <- c("M:/swim2/Reference/outputs/Reference.db")
names(dbs) <- c("Reference")

# setup connection to SQLite
library(RSQLite)
m = dbDriver("SQLite")

# define regional summary function
rgPopEmp <- function(zns){
   zn.. <- azone[as.character(azone$AZONE) %in% zns,c("AZONE","POPULATION","EMPLOYMENT","TSTEP")]
   cbind(POP=tapply(zn..$POPULATION, zn..$TSTEP,sum, na.rm=T),EMP=tapply(zn..$EMPLOYMENT, zn..$TSTEP,sum,na.rm=T))
} 

pdf("PopEmp_Growth.pdf", width=10,height=8)

   # connect to the database
   DB = dbConnect(m, dbs)
   # Pull link data
   azone = dbGetQuery(DB, "SELECT * FROM AZONE")
   azone$TSTEP <- as.numeric(azone$TSTEP)+1990
   
   aFields <-  dbGetQuery(DB, "SELECT * FROM ALLZONES")  
   
   # make a 2x1 plot with auto, truck, total, and then growth rates
   layout(matrix(1:2, byrow=T, ncol=2))
   par(mar=c(2,4.1,4.1,2.1), oma=c(2,2,2,2))
   
   # zones of interest to the West
   zn.. <- rgPopEmp(c("2280","2282"))     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Zones to the West", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # zone of interest to the East
   zn.. <- rgPopEmp(c("2281"))     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Zones to the East", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # zone of interest to the Canby
   zn.. <- rgPopEmp(c("521"))     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Canby to the East", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # Marion County
   zn.. <- rgPopEmp(aFields[aFields$COUNTY=="Marion","Azone"])     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Marion County Growth", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # Yamhill County
   zn.. <- rgPopEmp(aFields[aFields$COUNTY=="Yamhill","Azone"])     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Yamhill County Growth", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # Clackamas County
   zn.. <- rgPopEmp(aFields[aFields$COUNTY=="Clackamas","Azone"])     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Clackamas County Growth", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # Washington County
   zn.. <- rgPopEmp(aFields[aFields$COUNTY=="Washington","Azone"])     
   plot(as.numeric(rownames(zn..)),zn..[,"POP"], type="l",ylab="Population",main="Population Growth",xlab="Year")
   plot(as.numeric(rownames(zn..)),zn..[,"EMP"], type="l",ylab="Employment",main="Employment Growth",xlab="Year")
   mtext("Washington County Growth", side=3, line=0, outer=TRUE, cex=1.25) 
   
   # close connection to the database
   dbDisconnect(DB)
   
 
 dev.off()