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,
                     source='google',
                     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!

Our first day skiing. On the left is the basemap is a satellite photo, on the right it's a terrain map.
A post about: , , , , and

You May Also Enjoy