Created
January 21, 2021 01:09
-
-
Save boshek/80d813ae809b7bdd5f5adcc1534df439 to your computer and use it in GitHub Desktop.
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(tidyverse) | |
library(bcmaps) | |
library(tmap) | |
library(sf) | |
library(rayshader) | |
library(raster) | |
ws <- wsc_drainages() %>% | |
filter(SUB_SUB_DRAINAGE_AREA_NAME %in% c("Quesnel", "Clearwater (B.C.)", "Lower Fraser - Williams Lake")) | |
ws_raster <- cded_stars(ws) | |
cded1 <- tm_shape(ws_raster) + | |
tm_raster(legend.show = FALSE) + | |
tm_shape(ws) + | |
tm_borders(col = "black", lwd = 1) + | |
tm_layout(frame = FALSE) | |
tmap_save(tm = cded1, "cded-1.png", width = 1200, height = 675) | |
## bcmaps layers | |
bc <- bc_neighbours() | |
rivers <- watercourses_15M() | |
tm_shape(bc) + | |
tm_fill(col = 'name', legend.show = FALSE, palette = "PuBu") + | |
tm_shape(rivers) + | |
tm_lines(col = "aliceblue", lwd = 1) + | |
tm_layout(frame = FALSE) | |
tmap_save(r, "neigh.png", width = 1200, height = 675) | |
## Rayshader | |
csd <- census_subdivision() %>% | |
filter(CENSUS_SUBDIVISION_NAME == 'Powell River E') | |
cd_raster <- cded_raster(st_bbox(csd)) | |
elev_mat <- raster_to_matrix(cd_raster) | |
ray_shadow <- ray_shade(elev_mat, sunaltitude = 15, zscale = 10, multicore = TRUE) | |
ambient_shadow <- ambient_shade(elev_mat, zscale = 30) | |
elev_mat %>% | |
sphere_shade(zscale=10, texture="imhof1") %>% | |
add_shadow(ray_shadow, 0.4) %>% | |
add_water(detect_water(elev_mat)) %>% | |
plot_3d(elev_mat, zscale = 10, fov = 0, zoom = 0.5, windowsize = c(1200, 675)) | |
phivechalf = 30 + 60 * 1/(1 + exp(seq(-7, 20, length.out = 180)/2)) | |
phivecfull = c(phivechalf, rev(phivechalf)) | |
thetavec = -90 + 45 * sin(seq(0,359,length.out = 360) * pi/180) | |
zoomvec = 0.45 + 0.2 * 1/(1 + exp(seq(-5, 20, length.out = 180))) | |
zoomvecfull = c(zoomvec, rev(zoomvec)) | |
render_movie(filename = "movie.mp4", type = "custom", | |
frames = 360, phi = phivecfull, zoom = zoomvecfull, theta = thetavec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment