tylermorganwall / rayshader

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

fatal error crash in r studio upon using plot_3d #257

Open mathewsjoyy opened 1 year ago

mathewsjoyy commented 1 year ago

I have installed rayshader on R studio 4.2.2 using #remotes::install_github("tylermorganwall/rayshader")

However I have gone to plot a 3d plot and the graph opens in an external rgl window and shows the plot, but after 2-3 seconds, I get an error saying R Session Aborted and R encountered a fatal error.

I get the error upon using the below code :

matrix |>
  height_shade() |>
  plot_3d(heightmap = matrix,
          zscale = 100)
c-ryan7 commented 1 year ago

I get an identical error if I manually close XQuartz while my R session is open so maybe it's an issue with XQuartz?

mathewsjoyy commented 1 year ago

I get an identical error if I manually close XQuartz while my R session is open so maybe it's an issue with XQuartz?

What is XQuartz?

dmurdoch commented 1 year ago

XQuartz is the X11 server on MacOS that is used by the underlying graphics package (rgl). If you are on Windows or Linux you won't be using it.

tylermorganwall commented 1 year ago

Please run sessionInfo() and provide the output here.

tylermorganwall commented 1 year ago

FYI, there was a regression that causes random crashes in XQuartz on M1 macs that can be fixed by updating to the latest version (https://www.xquartz.org/releases/XQuartz-2.8.5_beta3.html).

king0708 commented 1 year ago

I have the same issue when trying to use plot_3d, with rayshader installed from github and updating to newest R and RStudio versions.

The code I was running is below, with the shapefile downloaded from the NPS: https://irma.nps.gov/DataStore/Reference/Profile/2223248

library(sf) library(rayshader) library(tidyverse) library(elevatr)

(modify based on where you downloaded shapefile:) moj <- st_read("data/mojave/moja_boundary.shp")

moj_elev <- get_elev_raster(moj, z = 10, clip = "location") mat <- rayshader::raster_to_matrix(moj_elev)

mat %>% rayshader::height_shade() %>% rayshader::plot_3d(heightmap = mat)

sessionInfo: R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

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

other attached packages: [1] elevatr_0.4.2 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2
[6] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2
[11] tidyverse_2.0.0 rayshader_0.35.1 sf_1.0-12

loaded via a namespace (and not attached): [1] utf8_1.2.3 generics_0.1.3 class_7.3-21 KernSmooth_2.23-20 [5] lattice_0.21-8 stringi_1.7.12 hms_1.1.3 digest_0.6.31
[9] magrittr_2.0.3 rgl_1.1.3 timechange_0.2.0 grid_4.3.0
[13] iterators_1.0.14 fastmap_1.1.1 foreach_1.5.2 doParallel_1.0.17 [17] jsonlite_1.8.4 progress_1.2.2 e1071_1.7-13 DBI_1.1.3
[21] fansi_1.0.4 scales_1.2.1 codetools_0.2-19 cli_3.6.1
[25] rlang_1.1.0 crayon_1.5.2 units_0.8-1 munsell_0.5.0
[29] base64enc_0.1-3 withr_2.5.0 tools_4.3.0 parallel_4.3.0
[33] tzdb_0.3.0 colorspace_2.1-0 vctrs_0.6.2 R6_2.5.1
[37] proxy_0.4-27 lifecycle_1.0.3 classInt_0.4-9 htmlwidgets_1.6.2 [41] pkgconfig_2.0.3 progressr_0.13.0 pillar_1.9.0 gtable_0.3.3
[45] glue_1.6.2 Rcpp_1.0.10 xfun_0.39 tidyselect_1.2.0
[49] rstudioapi_0.14 knitr_1.42 htmltools_0.5.5 compiler_4.3.0
[53] prettyunits_1.1.1 sp_1.6-0