Closed kunalbali closed 4 years ago
I have the following problem. Only water is displayed.
Check out this closed issue:
It did not work. I installed zlib in different ways including .dll copy and past and it still the same. In the first rayshader version it was working properly but plot_gg function. Today I updated it to the newest version to run plot_gg and 3d plot stopped rendering.
I will wait a bit longer for a solution.
@Jacksonmrodrigues Try installing rgl from the CRAN and see if that fixes you issue
@tylermorganwall Fixed!!! :)
However...
See https://github.com/tylermorganwall/rayshader/issues/51
Update to the latest version and try again
To @kunalbali, when I run your ggplot code I get this:
So I think there's something off in your original plotting code.
@tylermorganwall
after including
geom_raster(aes(fill = BCSMASS),na.rm = T)
I'm able to plot. but still the plot is not upto the mark.
You'll have to be more specific (and provide the full code to produce the figure), as that isn't enough information to troubleshoot what issue you are having.
Hi, I have a similar problem with the recently installed rayshader and rgl:
sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale: [1] LC_COLLATE=Estonian_Estonia.1257 LC_CTYPE=Estonian_Estonia.1257 LC_MONETARY=Estonian_Estonia.1257 [4] LC_NUMERIC=C LC_TIME=Estonian_Estonia.1257
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgl_0.107.27 rayrender_0.23.5 raster_3.5-2 rayshader_0.26.4 magick_2.7.3 rgdal_1.5-27
[7] sp_1.4-6 av_0.6.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 knitr_1.36 magrittr_2.0.1 hms_1.1.1 progress_1.2.2 munsell_0.5.0
[7] doParallel_1.0.16 colorspace_2.0-2 lattice_0.20-45 R6_2.5.1 rlang_0.4.12 fastmap_1.1.0
[13] foreach_1.5.1 tools_4.1.2 parallel_4.1.2 grid_4.1.2 xfun_0.28 png_0.1-7
[19] terra_1.4-20 htmltools_0.5.2 iterators_1.0.13 ellipsis_0.3.2 digest_0.6.28 lifecycle_1.0.1
[25] crayon_1.4.2 purrr_0.3.4 base64enc_0.1-3 htmlwidgets_1.5.4 vctrs_0.3.8 codetools_0.2-18
[31] compiler_4.1.2 scales_1.1.1 prettyunits_1.1.1 rayimage_0.6.2 jsonlite_1.7.2 pkgconfig_2.0.3
Here is the script I run: DEM = raster::raster( "63613_dem_1m.tif") polygon <- as(extent(510800, 511300, 6565300, 6565750), 'SpatialPolygons') crs(polygon) <- crs(DEM) # assign projection to the polygon DEM_crop<- crop(DEM, polygon) # crop DEM by polygon DEM_matrix = raster_to_matrix(DEM_crop)
image = stack("63613.tif") image_crop <- raster::crop(image, polygon) names(image_crop) = c("r","g","b")
image_crop_R = rayshader::raster_to_matrix(image_crop$r) # Red band image_crop_G = rayshader::raster_to_matrix(image_crop$g) # Green band image_crop_B = rayshader::raster_to_matrix(image_crop$b) # Blue band
image_crop_RGB = array(0,dim=c(nrow(image_crop_R),ncol(image_crop_R),3)) image_crop_RGB[,,1] = image_crop_R #Red layer image_crop_RGB[,,2] = image_crop_G #Blue layer image_crop_RGB[,,3] = image_crop_B #Green layer
image_crop_RGB = aperm(image_crop_RGB, c(2,1,3)) image_crop_RGB = scales::rescale(image_crop_RGB,to=c(0,1)) # rescale image
rayshader::plot_3d(image_crop_RGB, # RGB image DEM_matrix, # DEM windowsize = c(700,600), zscale = 0.6, shadowdepth = -50, zoom=0.7, phi=45,theta=-45,fov=70, background = "#D5D5D5", shadowcolor = "#5e5e5e") Links for the data: 63613_dem_1m.tif - https://tartuulikool-my.sharepoint.com/:i:/g/personal/burdun_ut_ee/EejpK0hLE09Eg-3XtKMIQ8YB55aOwGBqs_8CIQ3Fiy7gAg?e=WB3L2Q 63613.tif - https://tartuulikool-my.sharepoint.com/:i:/g/personal/burdun_ut_ee/EQUetQpvCthPq41fcw2L8YgBY7z1Z8d6iFlId6zLP9rRuA?e=CgKMrp
The problem is that I can't reinstall rgl from CRAN since the latest version there is 0.107.14 that doesn't work with rayshader_0.26.4. Do you have any suggestions on this?
I am adding two figures: how it should be and what I get with rgl_0.107.27 rayshader_0.26.4
Try updating rayshader and rgl to the latest versions on github remotes::install_github("tylermorganwall/rayshader")
and remotes::install_github("dmurdoch/rgl")
. There was a bug with the save_3dprint()
function that I just fixed, but it wouldn't have caused the error you're seeing—update and try again.
pm.txt
I am trying to plot3d with rayshader function of the attached data, but not able to get the desired output. It should come as an Indian country shape.
`pm = read.table(file="pm.txt", sep ="\t", header=T) head(pm) new_filecreate = ggplot(pm, aes(x=lon, y=lat, color=pm)) + geom_hex(bins = 120, size = 0.1) + scale_fill_distiller(palette = "Set1") +
ggtitle("PM2.5 Year 2017") +
theme_minimal()+ theme(legend.title=element_blank()) + theme(legend.text=element_text(size=14)) + theme(axis.title = element_text(face="plain",size="14",color="black"),axis.text=element_text(size=14,face="plain", color="black",hjust = 1)) + scale_x_continuous(quote(Longitude)) + scale_y_continuous(quote(Latitude)) + theme(legend.key.height = unit(0.5, "inch"))+ theme(legend.key.width = unit(0.2, "inch")) plot_gg(new_filecreate, width = 4, height = 3, multicore = TRUE,, windowsize=c(1000,1000),fov = 30) render_movie("pm", frames = 350)`
please provide some suggestion on this.