This repo houses code I use to create shaded relief graphics using the rayshader
R package by Tyler Morgan-Wall. I'm walking in the giant steps of Twitter user flotsam whose graphics originally inspired me, and tips + code snippets they shared helped immensely as I was just learning how to make these.
I've been making these graphics for a while (see my gallery) and wanted to share code from the start, but I was self-conscious about the state of my code. This repo is an effort to better organize my code so I can be confident in sharing it.
I also have an online store where I sell prints of a selection of these map. Find that store here: https://www.rayshadedesigns.com/.
Code to create each graphic has its own directory within the R/portraits directory, and helper functions can be found in the R/utils directory.
Graphics are written to an images
directory, but I'm not tracking it here because the graphics tend to be pretty large files. Instead, I copy the smaller version of the graphics (created for posting to platforms like Instagram or Reddit where file size limits are enforced) to the tracked_graphics directory so there is something to showcase here.
Here's a sample workflow you could use to repurpose this code for your own geography (assuming you've forked or otherwise copied this directory):
.new_portrait()
to start work on a portrait. This function takes one argument, which is the name of the map.
R/portraits
, with the directory name determined by map
argument in the the function call..new_portrait()
is loaded whenever you open the project via the .Rprofile
file, but it remains hidden from the environment because its name begins with a leading period.render_graphic.R
file, an example of which is R/portraits/bryce_canyon/render_graphic.R.
z
value so you're working with less data, and it's easier to iterate as you work to to get everything set how you want it.markup.R
(e.g. R/portraits/bryce_canyon/markup.R), adjusting the code as necessary for your given scenario.
{magick}
's gravity
argument to 'west' or 'east', and then adjusting the coords accordingly. You could achieve this directly with {magick}
as well if you want more direct control.utils
functions as I go, so earlier render and markup scripts might need updating to work with new functions. I am not maintaining backwards compatibility.