# Plotting paths in R

## Get the base map from google

In the plots below I use the satellite and terrain options of maptype. The day1 object is the centre of the map I want. Zoom controls the…zoom.

library(ggmap)
day1 <- c(lon=10.874062,
lat= 46.918028) # longitude of centre

basemap <- get_map(location=day1,
zoom=14,
maptype="satellite",
#color="bw"
)

## Plot ski run paths

The code below plots individual paths using the index, run_number. So that the ups, and downs, are a different colour, I cut the data using which. Usually I could just chuck up or down into colour, but this makes it easy to just plot runs down.

ggmap(basemap) +
geom_path(aes(x=longitude, y=latitude,
group=run_number),
size=0.4,
color="#0000FF4D",
alpha=0.6,
data=map_data[
which(map_data$up=='down'), ]) + geom_path(aes(x=longitude, y=latitude, group=run_number), size=0.7, color="#FF00004D", alpha=0.7, data=map_data[ which(map_data$up=='up'),
])

And the plots!

A post about: , , , , and
##### James Black

Epidemiologist and data scientist.