Skip to content

Instantly share code, notes, and snippets.

@tylermorganwall
Last active August 14, 2019 13:59
Show Gist options
  • Save tylermorganwall/33bf99d1fbbc581866b1d7a515d04080 to your computer and use it in GitHub Desktop.
Save tylermorganwall/33bf99d1fbbc581866b1d7a515d04080 to your computer and use it in GitHub Desktop.
rayshader visualization of HiRISE data
library(rayshader)
library(raster)
localtif = raster("DTEPC_027860_2525_027768_2525_G01.IMG")
elmat = matrix(raster::extract(localtif, raster::extent(localtif), buffer = 1000),
nrow = ncol(localtif), ncol = nrow(localtif))
small_full_res = elmat[7500:12000, 7000:11500]
#downsample the matrix
small_half_res = rayshader:::subsample_rect(small_full_res,
dim(small_full_res)[1]/2,
dim(small_full_res)[2]/2)
normals_half_res = calculate_normal(small_half_res,zscale = 1/20)
small_half_res %>%
sphere_shade(texture = "desert", normalvectors = normals_half_res) %>%
plot_3d(small_half_res, windowsize= c(1000,1000), baseshape = "hex", zscale=2)
theta = 1:360
zoomvec = 0.28 + 0.27 * 1/(1 + exp(seq(-15, 20, length.out = 180)/1))
zoomvecfull = c(zoomvec, rev(zoomvec))
render_movie("highrise.mp4", type = "custom",
theta = 1:360, zoom = zoomvecfull, fov = 70, phi=30, fps = 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment