Make your own Hyrule style map with rayshader

First, let's get some DEM data, OpenTopography might be a good place to start.

Load the data and our rayshader packages, resize the original matrix for a quick prototyping.

install.packages("remotes")
remotes::install_github("tylermorganwall/rayshader", force=TRUE)
remotes::install_github("tylermorganwall/rayimage", force=TRUE)

library(rayshader)
library(raster)
library(osmdata)
library(sf)
library(dplyr)
library(ggplot2)

somewhere_original = raster("somewhere.tif")
mat = raster_to_matrix(somewhere_original)
somewhere = resize_matrix(mat, 0.5)

Pick up colors for the map.

terrain_colors = c("#7e630b", "#b4ac75", "#ffffff")
contour_color = '#282000'
river_color = '#344043'
road_color = '#96915a'

Do elevation and shade.

base_map = somewhere %>%
  height_shade(texture=(grDevices::colorRampPalette(terrain_colors))(256)) %>%
  add_overlay(generate_contour_overlay(somewhere, nlevels=10, color=contour_color)) %>%
  add_shadow(lamb_shade(somewhere, zscale=1), 0.8) %>%
  add_shadow(texture_shade(somewhere,detail=8/10,contrast=9,brightness = 11), 0.1)

plot_map(base_map)

Get some data from OSM.

lat_range = c(25.9149388219094625, 26.2070713861842428)
long_range = c(119.1034149566263523, 119.6551378007304578)
osm_bbox = c(long_range[1],lat_range[1], long_range[2],lat_range[2])

highway = opq(osm_bbox) %>%
  add_osm_feature("highway", c("primary", "secondary")) %>%
  osmdata_sf()

waterway = opq(osm_bbox) %>%
  add_osm_feature("waterway", c("river")) %>%
  osmdata_sf()

Filter and print it out.

lines = st_transform(highway$osm_lines)
waterlines = st_transform(waterway$osm_lines)

ggplot(lines,aes(color=osm_id)) +
  geom_sf() +
  theme(legend.position = "none") +
  labs(title = "Highways")

ggplot(waterlines,aes(color=osm_id)) +
  geom_sf() +
  theme(legend.position = "none") +
  labs(title = "Waterways")

Add OSM data to the map.

rendered_map = base_map %>%
  add_overlay(generate_line_overlay(waterlines,extent = extent(somewhere_original),
                                    heightmap = somewhere, linewidth = 2, color=river_color)) %>%
  add_overlay(generate_line_overlay(lines,extent = extent(somewhere_original),
                                    heightmap = somewhere, linewidth = 2, color=road_color))

plot_map(rendered_map)

Render or save the map in 3D.

rendered_map %>%
  plot_3d(somewhere,zscale=60, windowsize=c(1200,800), baseshape="circle")

render_camera(theta=30,  phi=45, zoom=0.3,  fov=60)
render_snapshot()
# save_obj('somewhere.obj')