Last active
November 9, 2021 20:45
-
-
Save mikemahoney218/10322625b42bd763c30e070a56b8dada to your computer and use it in GitHub Desktop.
Code for my map for the 30 Day Map Challenge on November 09, 2021 ("Monochrome")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(raster) | |
library(rayshader) | |
library(terrainr) | |
library(sf) | |
Rainier <- tmaptools::geocode_OSM("Mount Rainier") | |
Rainier <- st_as_sf(as.data.frame(t(as.data.frame(Rainier$coords))), coords = c("x", "y"), crs = 4326) | |
zscale <- 5 | |
Rainier <- set_bbox_side_length( | |
Rainier, | |
15000 | |
) |> | |
get_tiles(resolution = zscale) |> | |
merge_rasters() |> | |
raster() | |
surface_matrix <- raster_to_matrix(Rainier) | |
color_pal <- function(n = 255, bias = 1) { | |
pal <- colorRampPalette( | |
c("black", "white"), | |
bias = bias | |
) | |
return(pal(n)) | |
} | |
surface_hillshade <- surface_matrix %>% | |
height_shade(texture = color_pal()) %>% | |
add_shadow(texture_shade(surface_matrix, detail = 0.9, brightness = 15), 0.7) %>% | |
add_shadow(ray_shade(surface_matrix, sunaltitude = 60, zscale = zscale, multicore = TRUE), 0) |> | |
add_shadow(ambient_shade(surface_matrix, zscale = zscale)) | |
plot_3d(surface_hillshade, | |
surface_matrix, | |
windowsize = c(2160, 1440), | |
zscale = zscale, | |
zoom = 0.5, | |
solid = FALSE, | |
theta = 40, | |
phi = 25) | |
render_highquality("20211109.png", lightintensity = 1000, parallel = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment