Site icon R-bloggers

RObservations #50: a journey across the United States with {mapBliss}

[This article was first published on r – bensstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

{mapBliss} is a package initially developed in my attempt to copy the offerings made available by a site (since defunct) called Atlas.co. Recently I was talking about the package in a group chat and someone reached out to me sharing that he traveled to 43 states in the United States and shared with me a list of his journey.

These are the visuals that were made:

In this blog, I share a new dataset available in {mapBliss} – us_travels. This dataset provides an interesting example for plotting more lengthy and complex adventures with {mapBliss}.

Loading the us_travels dataset

To load and preview the us_travels dataset, run the following code:

# Install the mapBliss package from GitHub if you haven't already
# devtools::install_packages("benyamindsmith/mapBliss")

# load the mapBliss library
library(mapBliss)
# load the us_travels dataset
data("us_travels")

# Preview the data
us_travels

# A tibble: 85 × 2
   location                       how  
   <chr>                          <chr>
 1 Mobile, Alabama, USA           car  
 2 Montgomery, Alabama, USA       car  
 3 Phoenix, Arizona, USA          car  
 4 Little Rock, Arkansas, USA     car  
 5 Los Angeles, California, USA   car  
 6 San Francisco, California, USA car  
 7 Oakland, California, USA       car  
 8 Half Moon Bay, California, USA car  
 9 San Diego, California, USA     car  
10 Stamford, Connecticut, USA     car  
# ℹ 75 more rows
# ℹ Use `print(n = ...)` to see more rows

Plotting the us_travels dataset

For plotting the us_travels dataset use the following snippet can be used:

library(mapBliss)
data("us_travels")

locations <- us_travels$location
# The how argument needs to be one 
# less than the number of the locations
how <- us_travels$how[-1] 

plot_hybrid_route_flex(
    addresses = locations, 
    how = how,
    radius = 1,
    label_text = ""
  )

This yields the following leaflet map:

The map themes be visually altered by changing the mapBoxTemplate argument.

Conclusion

The us_travels dataset provides a nice example for how the {mapBliss} package can be used to make beautiful maps of your travels around the world from the R console with minimal effort.

For framing these maps, I presently recommend using a platform like Canva. I additionally recommend checking out the {starBliss} package for making custom star maps of the night sky.

Here is a visual I made for a print of a trip this past summer with {mapBliss}, {starBliss} and Canva:



There are some GitHub issues open related to making ready to use frames (which have had some success) but there’s still some considerable effort required to accomplish the desired goal. If you think you can do it, feel free to open a pull request!

Want to see more of my content?

Be sure to subscribe and never miss an update!

To leave a comment for the author, please follow the link and comment on their blog: r – bensstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version