Coffeeneuring Challenge 2022

coffee map biking

Making a map of this year’s season

Harald Kliems https://haraldkliems.netlify.app/
2022-11-23

Almost every year I participate in the Coffeeneuring Challenge. You can find out more what coffeeneuring is and check out my past adventures over on my bike blog. But basically you have to bike to seven different coffee locations over the course of about six weeks. Now that the 2022 season is over, it seemed like a good opportunity to use my coffeeneuring data for the #30DayMapChallenge.

Show code

First we read in the spreadsheet where I kept track of my rides and destinations.

Show code
destinations <- read_sheet("https://docs.google.com/spreadsheets/d/1QaZ0BPOxJs-wUg0LMardUEjCvDd8h6GUirUl4VOzBDU/edit?usp=sharing") |> 
    separate(coordinates, into = c("lon", "lat"), sep = ", ", convert = T) |> 
    st_as_sf(coords = c("lat", "lon"))

destinations |> 
  kableExtra::kable()
name date category strava geometry
Crema Café 2022-10-15 coffee shop https://www.strava.com/activities/7966997401 POINT (-89.32413 43.07862)
Paradiddle’s Café 2022-10-09 coffee shop https://www.strava.com/activities/7939047633 POINT (-88.99078 43.19471)
Alice Good 2022-10-21 coffee shop https://www.strava.com/activities/7998212282 POINT (-89.53358 42.98808)
Hodge Podge 2022-11-06 coffee shop https://www.strava.com/activities/8079719303 POINT (-89.51824 42.99536)
Grace 2022-11-20 coffee shop https://www.strava.com/activities/8146150714 POINT (-89.51179 43.09536)
Rock River, Byron 2022-10-23 coffee outside https://www.strava.com/activities/8009683012 POINT (-89.25426 42.12329)
Leopold Pump Track 2022-10-30 coffee outside https://www.strava.com/activities/8044807447 POINT (-89.41957 43.03036)
Firefly 2022-10-16 coffee shop https://www.strava.com/activities/7973704511 POINT (-89.38395 42.92652)

We can map the destinations:

Show code
tmap_mode("view")
tm_shape(destinations) +
  tm_dots("category")

You may wonder about the one dot very far south. This was on a very long two-day ride to Illinois I did in October!

Next we add lines for the actual rides to these destinations. I don’t have access to the Strava API, and so I manually downloaded the gpx files and saved them in a folder. We use purrr to read them in and simplify the tracks with st_simplify to reduce the size.

Show code
process_gpx <- function(x){
  df <- read_GPX(x)
  df[[1]] |> #read_GPX outputs list
    st_simplify(dTolerance = 100) #distance is in meters
}

tracks <- list.files("data/", full.names = T) |> 
  map_dfr(process_gpx)

Let’s add the tracks to the above map:

Show code
  tm_shape(destinations)+
  tm_dots("category") +
  tm_shape(tracks) + 
  tm_lines()

We have all the data elements together now. Let’s create a nice static map. For that we need a base map. The Stamen Watercolor is always a nice option. Note the +c(...) after the bounding box command: This enlarges the bounding box in each direction so that our destinations aren’t at the very edge of the map and to make the map a little more square.

Show code
basemap <- read_osm(bb(destinations)+c(-.3, -.1, .3, .1), 
                    zoom = 10, 
                    type = "stamen-watercolor")

Rather than using color to distinguish between the category of destination, we can use custom icons with the tmap_icons() function. I created two icons in Inkscape, based on Fontawesome icons.

Coffee inside Coffee outside

Now it’s just a matter of putting all the layers together and making adjustments:

Show code
my_icons <- tmap_icons(c("img/coffee-inside.png", "img/coffee-outside.png"))

tmap_mode("plot")
tm_shape(basemap) +
  tm_rgb() +
  tm_shape(tracks) +
  tm_lines(lwd = 1.5, 
           col = "darkgreen") +
  tm_shape(destinations) +
  tm_symbols(
    shape = "category",
    shapes = my_icons,
    size = .1,
    title.shape = "Type of destination",
    border.col = NULL,
    alpha = .8
  ) +
  tm_text(
    "name",
    size = .5,
    remove.overlap = T,
    col = "white",
    just = "left",
    bg.color = "darkgrey",
    bg.alpha = .7
  ) +
  tm_compass() +
  tm_layout(
    legend.outside = T,
    main.title = "Harald’s 2022 Coffeeneuring Season",
    fontfamily = "Roboto Condensed"
  )

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-SA 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Kliems (2022, Nov. 23). Harald Kliems: Coffeeneuring Challenge 2022. Retrieved from https://haraldkliems.netlify.app/posts/2022-11-23-coffeeneuring-challenge-2022/

BibTeX citation

@misc{kliems2022coffeeneuring,
  author = {Kliems, Harald},
  title = {Harald Kliems: Coffeeneuring Challenge 2022},
  url = {https://haraldkliems.netlify.app/posts/2022-11-23-coffeeneuring-challenge-2022/},
  year = {2022}
}