Strava App Hexsticker

In this post, I want to describe how I created a hex sticker for one of my shiny apps. The app itself lets users interactively explore their Strava data.

Because I called the app SummitR, I decided to display one of the most famous summit finishes in cycling history: Alpe d’Huez.

I am using the following packages:

library(hexSticker)
library(tidyverse)
library(pins)

The hexSticker package is used to create the final hex sticker.

Because I already climbed Alpe d’Huez on a previous occasion, I can get the data already prepared from a private github repository. The data in the corresponding repository is organised as a pin:

alpe_dhuez_id <- "1714646144"
athlete_id <- "26845822"

board_register_github(repo = "duju211/strava_act", branch = "master")

df_act <- pin_get(
  str_glue("act_{alpe_dhuez_id}_{athlete_id}"), board = "github")

board_disconnect("github")

In raw table form the data of the activity looks like this:

## # A tibble: 5,326 x 11
##    moving velocity_smooth grade_smooth distance altitude  time   lat   lng
##    <lgl>            <dbl>        <dbl>    <dbl>    <dbl> <int> <dbl> <dbl>
##  1 FALSE              0            8.6      0       787      0  45.1  6.04
##  2 TRUE               0            8.6      2.1     787.     1  45.1  6.04
##  3 TRUE               2.3          8.6      4.5     787.     2  45.1  6.04
##  4 TRUE               2.3         10        7       788.     3  45.1  6.04
##  5 TRUE               2.3         11.9      9.3     788.     4  45.1  6.04
##  6 TRUE               2.3         12       11.6     788      5  45.1  6.04
##  7 TRUE               2.4         11.9     14.1     788.     6  45.1  6.04
##  8 TRUE               2.4         13.6     16.3     789.     7  45.1  6.04
##  9 TRUE               2.3         12       18.7     789      8  45.1  6.04
## 10 TRUE               2.4         12.6     21.1     789.     9  45.1  6.04
## # ... with 5,316 more rows, and 3 more variables: heartrate <int>,
## #   cadence <int>, watts <int>

Create a minimalistic plot of the activity. Only take variables lat and lng into account:

gg_act <- df_act %>% 
  ggplot(aes(x = lng, y = lat)) +
    geom_path(color = "white") +
    theme_void() +
    theme(legend.position = "none")

Plot the path of the activity on a black background:

gg_act +
  theme_dark()

Save the finished hex sticker as result. Use the official Strava color as background color.

sticker(
  gg_act, package="SummitR", p_size=20, s_x=1.1, s_y=.75, s_width=1.3,
  s_height=1, h_fill = "#fc4c02", h_color = "white",
  filename="static/post/hex_sticker.png")