tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.05k stars 211 forks source link

Ubuntu render_snapshot is not working #157

Closed AlexandreCandidoXavier closed 3 years ago

AlexandreCandidoXavier commented 3 years ago

Hi. Firstly, congratulations by the library! It seems to be very useful for those one that work with spatial data, like me.

I work with Python and I am really new in R. After some hours, I finished the installation of R a Rstudio in Ubuntu 20.04, as the packages that I understood are required. My problem is with "render_snapshot". I saw in the issues that it is a little recurrent. I tried myself found the solution of it, reading the issues, "google", but error:

Error in render_snapshot(clear = TRUE) : could not find function "render_snapshot"

remain.

Here is the code:

# remotes::install_github("tylermorganwall/rayshader")
options(device = "X11")
options(rgl.useNULL = FALSE)
library(rayshader)
library(ggplot2)
library(rgl)
library(rgdal)

ggdiamonds = ggplot(diamonds) +
  stat_density_2d(aes(x = x, y = depth, fill = stat(nlevel)), 
                  geom = "polygon", n = 100, bins = 10, contour = TRUE) +
  facet_wrap(clarity~.) +
  scale_fill_viridis_c(option = "A")

par(mfrow = c(1, 2))

plot_gg(ggdiamonds, width = 5, height = 5, raytrace = FALSE, preview = TRUE)
plot_gg(ggdiamonds, width = 5, height = 5, multicore = TRUE, scale = 250, 
        zoom = 0.7, theta = 10, phi = 30, windowsize = c(800, 800))
render_snapshot(clear = TRUE)

Here is my sessionInfo:

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=pt_BR.UTF-8       LC_NUMERIC=C               LC_TIME=pt_BR.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=pt_BR.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=pt_BR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgdal_1.5-23     sp_1.4-5         rgl_0.105.22     ggplot2_3.3.3    rayshader_0.24.6

loaded via a namespace (and not attached):
 [1] progress_1.2.2          tidyselect_1.1.0        xfun_0.22              
 [4] purrr_0.3.4             lattice_0.20-40         colorspace_2.0-0       
 [7] vctrs_0.3.7             generics_0.1.0          viridisLite_0.3.0      
[10] miniUI_0.1.1.1          htmltools_0.5.1.1       utf8_1.2.1             
[13] rlang_0.4.10            isoband_0.2.4           manipulateWidget_0.10.1
[16] pillar_1.5.1            later_1.1.0.1           glue_1.4.2             
[19] withr_2.4.1             DBI_1.1.1               foreach_1.5.1          
[22] lifecycle_1.0.0         munsell_0.5.0           gtable_0.3.0           
[25] raster_3.4-5            htmlwidgets_1.5.3       codetools_0.2-16       
[28] labeling_0.4.2          knitr_1.31              fastmap_1.1.0          
[31] doParallel_1.0.16       httpuv_1.5.5            crosstalk_1.1.1        
[34] parallel_3.6.3          fansi_0.4.2             Rcpp_1.0.6             
[37] terrainmeshr_0.1.0      xtable_1.8-4            scales_1.1.1           
[40] promises_1.2.0.1        magick_2.7.1            webshot_0.5.2          
[43] jsonlite_1.7.2          farver_2.1.0            mime_0.10              
[46] png_0.1-7               hms_1.0.0               digest_0.6.27          
[49] dplyr_1.0.5             shiny_1.6.0             grid_3.6.3             
[52] tools_3.6.3             magrittr_2.0.1          tibble_3.1.0           
[55] crayon_1.4.1            pkgconfig_2.0.3         MASS_7.3-51.5          
[58] ellipsis_0.3.1          prettyunits_1.1.1       assertthat_0.2.1       
[61] iterators_1.0.13        R6_2.5.0                compiler_3.6.3  

Here the screenshoot.

Screenshot from 2021-04-13 11-45-18

Let me know if you need more information.

Thanks.

tylermorganwall commented 3 years ago

The blank image is explained in the error from the rgl package: "this build of rgl does not support snapshots"

This happens when rgl does not detect OpenGL support when being installed. Run the following and try installing rgl. If this doesn't work, open an GH issue on the rgl package (dmurdoch/rgl).


$ sudo apt-get update
$ sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
AlexandreCandidoXavier commented 3 years ago

Thanks, it's working. I had just to reinstall rgl after commands above.