Site icon R-bloggers

Minimal

[This article was first published on r.iresmi.net, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Piton de La Fournaise – CC BY-NC-ND by Jean-Paul Tonnelier

Day 16 of 30DayMapChallenge: « minimal » (previously).

Bare Réunion…

library(rayshader)
library(raster)
library(tidyverse)
library(fs)
library(httr)
library(glue)

data_dir <- path_expand("~/data/bdalti/974")

# https://geoservices.ign.fr/bdalti
if (!dir_exists(data_dir)) {
  dir_create(data_dir)
  
  GET("https://wxs.ign.fr/aqd29otkz2hofiee5pb0fygn/telechargement/prepackage/BDALTI-25M_PACK_REU_14-12-2020$BDALTIV2_2-0_25M_ASC_RGR92UTM40S-REUN89_D974_2016-03-11/file/BDALTIV2_2-0_25M_ASC_RGR92UTM40S-REUN89_D974_2016-03-11.7z",
      write_disk(glue("{data_dir}/dl.7z")))
  
  system(glue("7z e -y -o{data_dir} {data_dir}/dl.7z"))
}

# We get a bunch of ASCII files : open and merge, convert to matrix used by rayshader
elmat <- dir_ls(data_dir, glob = "*.asc") %>% 
  map(raster) %>% 
  reduce(merge) %>% 
  raster_to_matrix()

elmat %>%
  sphere_shade(texture = "desert") %>%
  add_shadow(ray_shade(elmat, zscale = 3), 0.5) %>%
  add_shadow(ambient_shade(elmat), 0) %>%
  plot_3d(elmat, zscale = 10, fov = 0, theta = 135, zoom = 0.75, phi = 45, windowsize = c(1000, 800))

render_snapshot("reunion_3d.jpeg")

Bare Réunion
To leave a comment for the author, please follow the link and comment on their blog: r.iresmi.net.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version