Closed SbastianGarzon closed 1 year ago
Describe the bug The function render_tree creates trees flipped 90 degrees in the (y / z?) axis:
Session Info
sessionInfo() R version 4.2.2 Patched (2022-11-10 r83330) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.1 LTS
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=nl_NL.UTF-8 [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=nl_NL.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices datasets utils methods base
other attached packages: [1] osmdata_0.1.10 lidR_4.0.1 geojsonsf_2.0.3 rayshader_0.30.4 elevatr_0.4.2 rayrender_0.29.0 dplyr_1.0.10 sf_1.0-9 [9] raster_3.6-13 sp_1.5-1
Reproducible Example
Here is a reproducible example:
library(rayshader) library(sf) library(elevatr) # Define central point central_point = c(4.3,52.0) # Transform into a CRS central_point|> st_point() |> st_sfc(crs = 4326) |> st_transform(st_crs(7415))-> central_point # Download elevation raster around central point aoi_distance <- units::as_units(100,"m") elevation_data = elevatr::get_elev_raster( locations = st_buffer(central_point, dist=aoi_distance),z=14) elevation_matrix = raster_to_matrix(elevation_data) # Create forest set.seed(1) coord <- st_coordinates(central_point) trees <- data.frame(lat=runif(300,min=0,max=1000)+coord[[2]], lon=runif(300,min=0,max=1000)+coord[[1]], elevation =runif(300)+10) trees_sf <- st_as_sf(x=trees,coords = c("lon","lat"),crs=st_crs(central_point)) # Start rayshader.... elevation_matrix %>% height_shade() %>% plot_3d(elevation_matrix,baseshape = "rectangle") render_tree(lat=trees$lat, long = trees$lon, canopy_height = 20, baseshape = "rectangle", extent = raster::extent(elevation_data), heightmap = elevation_matrix) # Checking location of trees plot(elevation_data) plot(trees_sf,add=TRUE)
Additional information
I managed to reproduce the National Mall example. However the trees are also flipped 90 degrees.
It appears you have an outdated version of rayshader (v0.30.4)—install the latest version from github (v0.33.7) and you should not have this problem.
remotes::install_github("tylermorganwall/rayshader")
Describe the bug The function render_tree creates trees flipped 90 degrees in the (y / z?) axis:
Session Info
sessionInfo() R version 4.2.2 Patched (2022-11-10 r83330) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.1 LTS
Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8
LC_MONETARY=nl_NL.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=nl_NL.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices datasets utils methods base
other attached packages: [1] osmdata_0.1.10 lidR_4.0.1 geojsonsf_2.0.3 rayshader_0.30.4 elevatr_0.4.2 rayrender_0.29.0 dplyr_1.0.10 sf_1.0-9
[9] raster_3.6-13 sp_1.5-1
Reproducible Example
Here is a reproducible example:
Additional information
I managed to reproduce the National Mall example. However the trees are also flipped 90 degrees.