source("~/Projects/NBI/R/convert2016.R")
nbi <- convert2016("~/Data/2016hwybronlyonefile.zip")
library(MazamaSpatialUtils)
library(sp)
library(rgdal)
setSpatialDataDir("~/Data/Spatial")
loadSpatialData("USCensusCounties")
loadSpatialData("USCensusStates")
conus <- subset(USCensusStates, !stateCode %in% c("HI", "AK","GU","AS", "PR", "HI", "VI", "MP"))
conus <- rmapshaper::ms_simplify(conus, .05)
nbisp <- subset(nbi, is.na(latitude) == F)
nbisp <- subset(nbisp, is.na(longitude) == F)
coordinates(nbisp) <- c("longitude", "latitude")
proj4string(nbisp) <- proj4string(USCensusStates)
ne <- subset(nbisp, stateCode == "NE")
neCounties <- subset(USCensusCounties, stateCode == "NE")
ne$county <- getUSCounty(ne$longitude, ne$latitude, dataset = "neCounties", stateCode = "NE")

What is so unique about Nebraska?

Nebraska is an interesting case for a couple of reasons. Bridges are not equally distributed throughout the country. There are a lot more bridges in the Eastern half. Fewer in the mountainous, less-developed west. Nebraska lies right in the middle of this divide, with a stark difference in the density of bridges in the eastern and western half of the state.

plot(spTransform(conus, CRS("+init=epsg:5071")))
plot(subset(spTransform(conus, CRS("+init=epsg:5071")), stateCode == "NE"), border = "red", add = TRUE, lwd = 5)
points(spTransform(nbisp, CRS("+init=epsg:5071")), pch = 17, cex = .05)
title("Bridges in the Continental US")

Nebraska is also an interesting case when it comes to the age of bridges in the state. In most states, the peak of bridge building was in the 60's or near that time. In contrast, Nebraska and Oklahoma built the most bridges in the 30's. For these reasons, we will be taking a closer look at bridges in Nebraska to explore their geography and history.

getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}

decadeBreaks <- c(-Inf, seq(1800, 2020, by = 10))
decadeBuilt <- .bincode(nbi$yearBuilt, breaks = decadeBreaks)
decadeBuilt <- c("<1800", as.character(seq(1800,2020,by = 10)))[decadeBuilt]
modeDecadeByState <- aggregate(decadeBuilt ~ nbi$stateCode , FUN = getmode)
modeDecadeByState$decadeBuilt <- as.numeric(modeDecadeByState$decadeBuilt)
modeAgeIndex <- .bincode(2000-modeDecadeByState$decadeBuilt, breaks = seq(9,79, by = 10))
names(modeAgeIndex) <- modeDecadeByState$`nbi$stateCode`
decadeColors <- RColorBrewer::brewer.pal(7, "PuRd")

plot(spTransform(conus, CRS("+init=epsg:5071")), col = decadeColors[modeAgeIndex[conus$stateCode]])
plot(subset(spTransform(conus, CRS("+init=epsg:5071")), stateCode == "NE"), lwd = 5, add = TRUE)
legend("bottomleft", c("1930s", "1940s", "1950s", "1960s", "1970s", "1980s", "1990s"), pch = 15, col = decadeColors[7:1])
title("Most Prolific Bridge-Building Decade")

Overall Distribution of Bridges in Nebraska

plot(subset(conus, stateCode == "NE"))
points(subset(ne, water == 1), pch = 2, cex = .1, col = "blue")
points(subset(ne, water == 0), pch = 2, cex = .3, col = "red")
title("All bridges in Nebraska")
legend("bottomleft", c("Bridges over water", "Bridges not over water"),
       pch = 17, col = c("blue", "red"), title = "Legend")

We see two very different types of geography when we look at bridges that span water versus bridges that do not span water, like overpasses. Bridges that do not span water will generally only be on large roads and highways where an overpass or underpass is needed. Thus, these bridges directly follow the interstate.

On the other hand, bridges that do span water follow Nebraska's physical geography. In the western half of the state, the interstate generally follows the Platte river, but when it diverges in the east, we can easily follow the shape of the Platte as it curves up towards Omaha. Tributataries flow in from the north. In the southern part of the state, bridges outline the shape of the Republican river and its tributaries.

knitr::include_graphics("./localImages/Nebraska_ref_2001.jpg")

Why are there so many more bridges in the Eastern half of the state? Western Nebraska is home to the Sandhills, arid and scantily populated. There are bridges where water and roads intersect and Eastern Nebraska is richer in both. However, many parts of Eastern Nebraska are relatively sparsely-populated farmland. Why, then, are there so many bridges? Let's zoom in a bit.

gmap <- RgoogleMaps::GetMap( maptype = "satellite", zoom = 11, center = c(42, -97.8))
RgoogleMaps::PlotOnStaticMap(gmap, lat = ne@coords[,2], lon = ne@coords[,1], pch = 16, col = "yellow", axes = TRUE, mar = c(2,2,2,2))

We are looking at a corner of Northeastern Nebraska. Now that we can make out individual bridges, we can see that they seem to be relatively evenly-spaced, following what must be rivers. If we take a look at a sattelite image of this same area, we see that, indeed, there are evenly spaced roads outlining the squares of each individual farming plot, which form nice regularly-spaced bridges where they intersect with rivers.

Bridge Age

hist(ne$yearBuilt, xlab = "Year Built", main = "Year Built", n = 100)

When were Nebraska's bridges built? It appears that close to half of them were built in one year in the 1930s. We will examine that phenomenon more in a minute. Ignoring that one outlier year, most bridges were built in the last 50 years or so. Previous to that, there are peaks every 5 to 10 years, which is most likely due to rounding in estimates of each bridge's founding year. Bridge building seems to start taking off around 1930, perhaps as part of depression-relief projects. There is the huge outlier of 1935, and then in the 40's, we see a dip again during the war. Besides 1935, most bridges were built in the last 50 years or so, with a peak in the early 60's, after the signing of the Federal Highway Act spurred road building, with a decline in bridge building since around 1990.

Let's watch it happen.

yearlyBridgePlot <- function(df, year){
    layout(matrix(c(1,2), 2, 1), heights = c(7,3))
    par(mar = c(2,2,2,2))
    plot(subset(conus, state == "NE"))
    with(subset(df, yearBuilt <= year - 10), 
         points(longitude, latitude, cex = .3, pch = 17, col = "grey"))
    for(i in 1:9){
      with(subset(df, yearBuilt == year - i),
           points(longitude, latitude, cex = .4, pch = 17, 
                  col = adjustcolor("grey", red.f = 2-i/10, green.f = i/10, blue.f = i/10)))
    }
    with(subset(df, yearBuilt == year), points(longitude, latitude, pch = 24, cex = 1, bg = "red", col = "black"))
    title(as.character(year))
    par(mar = c(1,4,5,4), mgp = c(2,.5,0), yaxs = "i")
    plot(NA, xlim = c(1885, 2015), ylim = c(0,10), axes = F, ann = F)
    axis(3, at = seq(1885, 2015, by = 10))
    points(year, 8.8, pch = 17, cex = 2)
    title("Year")
}

animation::saveHTML(for(i in min(ne$yearBuilt):max(ne$yearBuilt)){
        yearlyBridgePlot(df = ne, year = i)
      }, 
      interval = .2, htmlfile = "nebraska_animation.html", autobrowse = FALSE)


htmltools::includeHTML("./nebraska_animation.html")

All this makes sense with our understanding of US history. So what happened in Nebraska in 1935?

1935 Republican River Flood

In June of 1935 a massive flood overflowed the banks of the Republican River, killing nearly 100 Nebraskan people and 46,500 Nebraskan chickens. It wiped out 341 miles of Nebraskan highways and 57,000 acres of farmland. It was a massive flood. As one may expect, many bridges were washed out. Here are some examples.

knitr::include_graphics(c("./localImages/bridge1.jpg","./localImages/WebberBridgeB.jpg"))

With so many bridges destroyed, we would expect that just as many bridges had to be rebuilt. Thus, is the huge spike in bridge building in 1935 a sign of enthusiastic expansion of road networks, an indication of the aftermath of a natural disaster which destroyed many bridges, or simply an artifact of human fallibility in recording data? Let's take a closer look at the bridges built in 1935.

floodBridges <- subset(ne, yearBuilt == 1935)

According to our dataset, r nrow(floodBridges) were built in 1935. That's a lot. 307 highway bridges were reportedly destroyed in the flood, and, we expect, rebuilt shortly thereafter. This does not account for railroad bridges or bridges on small county roads, so it is fair to expect the total number of reconstructed bridges to be significantly higher than 307. Is it plausible that the vast majority of bridges built in 1935 were non-highway bridges destroyed in the flood? They do seem to be primarily non-highway bridges. The average daily traffic for bridges built in 1935 is r mean(floodBridges$averageCarCount) vehicles whereas the average daily traffic for all Nebraskan bridges is r mean(ne$averageCarCount) vehicles. The vast majority of the bridges built in 1935 carry 100 cars or fewer. In fact, only 11% of the bridges built in 1935 carry over 100 cars per day, on average, which indicates that they are generally small, non-highway bridges, the kind that would easily get washed out in a flood. However, it is also likely that most large bridges were built more recently, once major highways were developed.

hist(floodBridges$averageCarCount, n = 100000, main = "Traffic on Bridges Built in 1935", xlab = "Average Daily Traffic")
hist(floodBridges$averageCarCount, n = 100000, xlim = c(0,500), main = "Zoomed-in Histogram of Traffic on Bridges Built in 1935", xlab = "Average Daily Traffic")

Now, let's take a look at where these bridges actually are.

plot(subset(USCensusStates, stateCode == "NE"))
points(floodBridges, pch = 17, cex = .5)
title("Bridges built in 1935")

The Republican River winds through Southern Nebraska. Many of the 1935 bridges were, indeed, built near the Republican River. However, just as many, if not more, were built in other parts of Nebraska. It seems most likely that the huge spike in bridge building was more due to something like age estimations by surveyors which defaulted to 1935.

breaks <- c(0,seq(16,136, by = 20))
neColors <- RColorBrewer::brewer.pal(7, "PuRd")
colorIndex <- .bincode(ne$age, breaks = breaks)
ne$colorIndex <- colorIndex
plot(subset(USCensusStates, stateCode == "NE"))
points(ne$longitude, ne$latitude, cex = .3, pch = 17, col = neColors[colorIndex])
legend("bottomleft", c("1880-1900", "1900-1920", "1920-1940", "1940-1960", "1960-1980", "1980-2000", "2000-2017"), pch = 17, col = neColors[7:1])
breaks <- c(0,seq(16,136, by = 20))
neColors <- RColorBrewer::brewer.pal(7, "PuRd")
colorIndex <- .bincode(ne$age, breaks = breaks)
breaks <- c(0,seq(16,136, by = 20))
plot(subset(USCensusStates, stateCode == "NE"))
points(subset(ne, water == 0), cex = .5, pch = 17, col = neColors[colorIndex])

Traffic

par(mar = c(4,0,4,0))
layout(matrix(c(2,1),1,2), widths = c(2,8))
plot(subset(USCensusStates, stateCode == "NE"))
points(ne, pch = 2, cex = ne$averageCarCount/20000)
title("Traffic on Nebraska's Bridges")
plot.new()
legend("left", c("1,000", "10,000", "100,000"), pch = 2, pt.cex = c(1000/20000, 10000/20000, 100000/20000), title = "Daily motor Traffic", y.intersp = 2)
trafficColors <- RColorBrewer::brewer.pal(9,"YlOrRd")
breaks <- c(seq(0, log(max(ne$averageCarCount)), length = 10))
colorIndex <- .bincode(log(ne$averageCarCount), breaks = breaks)
plot(subset(USCensusStates, stateCode == "NE"))
points(ne, pch = 17, col = trafficColors[colorIndex], cex = log(ne$averageCarCount)/20)
legend("bottomleft", c('100','1000','10000','100000'), col = trafficColors[c(4,6,7,9)], pch = 17, pt.cex = log(c(100,1000,10000,100000))/20, title = "Daily Motor Traffic")
title("Traffic on Nebraska's Bridges")

As expected, traffic is heaviest along the highways. There are particular high-traffic clumps at Omaha and Lincoln. Most bridges have low traffic. Less than about 1,000 vehicles per day and they barely show up on the map.

Aggregated by county:

To see how bridge age is distributed geographically, let's aggregate the data by county.

meanAgeByCounty <- aggregate(data=ne, age~county, FUN = mean)
breaks <- c(24.4, seq(30,55, by = 5), 60.2)
colorIndex <- .bincode(meanAgeByCounty$age, breaks = breaks)
names(colorIndex) <- meanAgeByCounty$county
plot(neCounties, col = neColors[colorIndex[neCounties$countyName]])
legend("bottomleft", c("25-30", "30-35", "35-40", "40-45", "45-50","50-55", "55-60"), pch = 15, col = neColors, title = "Mean Bridge Age")
title("Mean bridge age by county")

No clear patterns arise when we look at the mean age by county. Let's take a look at the mode year which bridges were built in each county.

getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}

modeYearByCounty <- aggregate(data = ne, yearBuilt~county, FUN = getmode)
hist(modeYearByCounty$yearBuilt)
breaks <- c(seq(1929, 1999, by = 10), 2017)
modeIndex <- .bincode(modeYearByCounty$yearBuilt, breaks = breaks)
modeColors <- RColorBrewer::brewer.pal(8, "PuRd")
names(modeIndex) <- modeYearByCounty$county
plot(neCounties, col = modeColors[8:1][modeIndex[neCounties$countyName]])
legend("bottomleft", c("1930s", "1940s", "1950s", "1960s", "1970s", "1980s", "1990s", "2000s"), pch = 15, col = modeColors[8:1])
points(ne, pch = 17, cex = .2, col = "green")
title("Mode year bridges were built")

As expected, in most counties, most bridges were built in the 1930s. There is a group of counties near the middle of the state where more bridges were built more recently. When we plot the location of each bridge over the map in green, we see that these counties in general have fewer bridges than other counties, which may indicate that they have been developed more recently. There are even some counties which do not include any bridges in the database. People living in these counties may have never even seen a bridge in their lives.



MazamaScience/NBI documentation built on May 29, 2019, 4:50 p.m.