Mapping Travel Times with malariaAtlas and Friction Surfaces

Accessibility-to-cities map, courtesy of the study authors.

Travel Time Tutorial

## Packages
library(gdistance)
library(abind)
library(rje)
library(ggplot2)
library(malariaAtlas)
## Plot defaults
theme_set(theme_minimal(base_size=14))
USA.shp <- malariaAtlas::getShp(ISO = "USA", admin_level = "admin1")
analysis.shp <- USA.shp[USA.shp@data$name=="Colorado",]
plot(analysis.shp, main="Shape for Clipping")
Looks like a square state to me!
friction <- malariaAtlas::getRaster(
surface = "A global friction surface enumerating land-based travel speed for a nominal year 2015",
shp = analysis.shp)
malariaAtlas::autoplot_MAPraster(friction)
T <- gdistance::transition(friction, function(x) 1/mean(x), 8) 
T.GC <- gdistance::geoCorrection(T)
## Point locations
point.locations <- read.csv(file = points.filename)
names(point.locations) <- c("X_COORD", "Y_COORD", "name")
# Keep only point coordinates within the shapefile bounds
coordinates(point.locations) <- ~ X_COORD + Y_COORD
proj4string(point.locations) <- proj4string(analysis.shp)
overlap <- over(point.locations, analysis.shp)
point.locations <- point.locations[!is.na(overlap$gid),]
points <- as.matrix(point.locations@coords)
access.raster <- gdistance::accCost(T.GC, points)
p <- malariaAtlas::autoplot_MAPraster(access.raster, 
shp_df=analysis.shp, printed=F)
full_plot <- p[[1]] + geom_point(data=data.frame(point.locations@coords),
aes(x=X_COORD, y=Y_COORD)) +
scale_fill_gradientn(colors = rev(rje::cubeHelix(gamma=1.0,
start=1.5,
r=-1.0,
hue=1.5,
n=16)),
name="Minutes \n of Travel") +
ggtitle("Travel Time to Most Accessible Peak") +
theme(axis.text=element_blank(),
panel.border=element_rect(fill=NA, color="white"))
print(full_plot)
Highlight of the south-central edge of the map, around Windom Peak.

Discussion and Caveats

 by the author.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Child Trafficking in India - In depth analysis and visualisation

How to put error bars on your data: the easy way

Battle of neighbourhoods

Find a location for opening a restaurant

ABOUT THE DECISION TREES

Chapter 1 : Supervised Learning and Naive Bayes Classification — Part 2 (Coding)

The Poisson Deviance for Regression

Let’s do some machine learning with R

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Amelia Bertozzi-Villa

Amelia Bertozzi-Villa

Modeler.

More from Medium

Why Data Analytics?

Table of installed packages in R

Cozy Collecting, Case Study: Getting a Decade’s Worth of Weather Data in R

Amazon Bestsellers — EDA & KMeans with R