tylermorganwall / rayshader

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

Weird stripes when using plot_map #134

Closed DavidDHofmann closed 3 years ago

DavidDHofmann commented 3 years ago

Hello

I encountered an issue with the plot_map() function. I am trying to plot an elevation map of Switzerland. If I remove the NAs, the plot looks fine. However, whenever the area outside the country contains NA values the final plot depicts some weird stripes. If I remember correctly, the same code worked fine a few months ago. Any idea what could cause this? Here's the code:

# Load required packages
library(rayshader)
library(raster)

# Download elevation data
elev <- getData("alt", country = "CHE")

# Plot without NAs
elev %>%
  reclassify(rcl = c(NA, NA, 0)) %>%
  raster_to_matrix() %>%
  sphere_shade(., texture = "imhof1") %>%
  plot_map()

image

# Plot with NAs
elev %>%
  raster_to_matrix() %>%
  sphere_shade(., texture = "imhof1") %>%
  plot_map()

image

# SessionInfo
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.3

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

locale:
 [1] LC_CTYPE=de_CH.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_CH.UTF-8        LC_COLLATE=de_CH.UTF-8    
 [5] LC_MONETARY=de_CH.UTF-8    LC_MESSAGES=de_CH.UTF-8   
 [7] LC_PAPER=de_CH.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] raster_3.3-13    sp_1.4-4         rayshader_0.19.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5              pillar_1.4.6            compiler_3.6.3         
 [4] later_1.1.0.1           prettyunits_1.1.1       base64enc_0.1-3        
 [7] iterators_1.0.13        tools_3.6.3             getPass_0.2-2          
[10] progress_1.2.2          digest_0.6.27           uuid_0.1-4             
[13] lattice_0.20-41         jsonlite_1.7.1          evaluate_0.14          
[16] lifecycle_0.2.0         pkgconfig_2.0.3         rlang_0.4.7            
[19] foreach_1.5.1           IRdisplay_0.7.0         shiny_1.5.0            
[22] crosstalk_1.1.0.1       rgdal_1.5-18            IRkernel_1.1.1         
[25] parallel_3.6.3          xfun_0.18               fastmap_1.0.1          
[28] repr_1.1.0              knitr_1.30              vctrs_0.3.4            
[31] htmlwidgets_1.5.2       hms_0.5.3               grid_3.6.3             
[34] webshot_0.5.2           manipulateWidget_0.10.1 R6_2.5.0               
[37] rgl_0.100.54            pbdZMQ_0.3-3            magrittr_1.5           
[40] codetools_0.2-16        promises_1.1.1          ellipsis_0.3.1         
[43] htmltools_0.5.0         xtable_1.8-4            mime_0.9               
[46] httpuv_1.5.4            miniUI_0.1.1.1          doParallel_1.0.15      
[49] crayon_1.3.4            Cairo_1.5-12.2         
tylermorganwall commented 3 years ago

Thanks for the bug report! This is fixed in the latest version (v0.20.0).