Skip to content

Instantly share code, notes, and snippets.

@SimonCoulombe
Created January 28, 2019 16:51
Show Gist options
  • Save SimonCoulombe/90ba586d9bf5fa08f48378d0616b5647 to your computer and use it in GitHub Desktop.
Save SimonCoulombe/90ba586d9bf5fa08f48378d0616b5647 to your computer and use it in GitHub Desktop.
# rayshader.com
#sudo apt-get install libfftw3-dev libtiff5-dev
#sudo apt-get install libcairo2-dev
#sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
# install.packages("tiff")
# sudo R , install.packages("rgl")
#devtools::install_github("tylermorganwall/rayshader")
# Canadian Digital Elevation Model
# https://open.canada.ca/data/en/dataset/7f245e4d-76c2-4caa-951a-45d1d2051333
library(rayshader)
library(tidyverse)
library(sf)
library(leaflet)
# figure out which raster I need to download ----
# download.file("http://ftp.geogratis.gc.ca/pub/nrcan_rncan/vector/index/nts_snrc.zip",
# destfile= here::here("nts_snrc.zip"))
# utils::unzip(here::here("nts_snrc.zip"),
# exdir =here::here("") )
#
# z <- read_sf(here::here("","nts_snrc_50k.shp" ))
# z %>% head(10000) %>% leaflet %>% addTiles() %>%
# addPolygons(label = ~htmltools::htmlEscape(NTS_SNRC))
# ANSWER : parc des hautes gorges de la malbaie = = 021M15 021M16 022D02 022D01
# http://ftp.geogratis.gc.ca/pub/nrcan_rncan/elevation/cdem_mnec/021/cdem_dem_021M_tif.zip
# http://ftp.geogratis.gc.ca/pub/nrcan_rncan/elevation/cdem_mnec/022/cdem_dem_022D_tif.zip
download.file("http://ftp.geogratis.gc.ca/pub/nrcan_rncan/elevation/cdem_mnec/021/cdem_dem_021M_tif.zip",
destfile= here::here("cdem_dem_021M_tif.zip"))
utils::unzip(here::here("cdem_dem_021M_tif.zip"),
exdir =here::here("") )
# download.file("http://ftp.geogratis.gc.ca/pub/nrcan_rncan/elevation/cdem_mnec/022/cdem_dem_022D_tif.zip",
# destfile= here::here("cdem_dem_022D_tif.zip"))
#
# utils::unzip(here::here("cdem_dem_022D_tif.zip"),
# exdir =here::here(") )
eltif <- raster::raster(here::here("","cdem_dem_021M.tif" ))
elmat1 = matrix(raster::extract(eltif,raster::extent(eltif),buffer=10000),nrow=ncol(eltif),ncol=nrow(eltif))
malbaie <- elmat1[6600:8000, 1:1500]
ambmat = ambient_shade(malbaie)
malbaie %>%
sphere_shade() %>%
add_water(detect_water(malbaie )) %>%
add_shadow(ambmat) %>%
plot_map()
malbaie %>%
sphere_shade() %>%
add_water(detect_water(malbaie )) %>%
add_shadow(ambmat) %>%
plot_3d(malbaie, baseshape = "hex")
render_snapshot() ## black screen ?
#c022d <- raster::raster(here::here("","cdem_dem_022D.tif" ))
## high resolution
#High Resolution Digital Elevation Model (HRDEM) - CanElevation Series (not used)
#https://open.canada.ca/data/en/dataset/957782bf-847c-4644-a757-e383c0057995
#
#
# download.file("http://ftp.maps.canada.ca/pub/elevation/dem_mne/highresolution_hauteresolution/Projects_Footprints.zip",
# destfile= here::here("Projects_Footprints.zip"))
#
# utils::unzip( here::here("Projects_Footprints.zip"),
# exdir =here::here("") )
# here::here("/Projects_Footprints.zip")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment