Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_shadow() no longer rescales shadow matrix when original hillshade is rescaled via add_overlay() [BUG] #326

Open
apsteinmetz opened this issue Nov 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@apsteinmetz
Copy link

Describe the bug
I have an image overlay with different dimensions than my elevation matrix. I want add_overlay() to rescale the original elevation matrix. If I add a shadowmap created from the original elevation matrix the shadowmap is NOT rescaled to match the hillshade (the docs say rescaling is the default) but instead throws a "Not a Matrix" error. This is a new error on code that used to work (a year ago).

Reproducible Example

dim(elev_matrix)
# [1]  755 1774
dim(gwl_png)
# [1] 3549 1510    3

# this works
gwl <- elev_matrix |>
  sphere_shade() |>
  add_overlay(gwl_png, rescale_original = FALSE) |>
  add_shadow(lamb_shade(elev_matrix))

# this works
gwl <- elev_matrix |>
  sphere_shade() |>
  add_overlay(gwl_png, rescale_original = TRUE)

# this does NOT work
gwl <- elev_matrix |>
  sphere_shade() |>
  add_overlay(gwl_png, rescale_original = TRUE) |>
  add_shadow(lamb_shade(elev_matrix))

# Error: Not a matrix.

**Session Info**
Include the output of the `sessionInfo()` function here. Issues will be closed without providing this as a minimum.

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

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

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

other attached packages:
 [1] lubridate_1.9.3  forcats_1.0.0    stringr_1.5.1    dplyr_1.1.4      purrr_1.0.2      readr_2.1.5      tidyr_1.3.1      tibble_3.2.1     ggplot2_3.5.1    tidyverse_2.0.0 
[11] maptiles_0.8.0   osrm_4.2.0       smoothr_1.0.1    raster_3.6-30    sp_2.1-4         terra_1.7-83     sf_1.0-19        png_0.1-8        elevatr_0.99.0   rayshader_0.37.3

loaded via a namespace (and not attached):
 [1] DBI_1.2.3             httr2_1.0.6           rlang_1.1.4           magrittr_2.0.3        e1071_1.7-16          compiler_4.3.0        callr_3.7.6          
 [8] vctrs_0.6.5           pkgconfig_2.0.3       crayon_1.5.3          fastmap_1.2.0         magick_2.8.5          utf8_1.2.4            promises_1.3.0       
[15] tzdb_0.4.0            ps_1.8.1              chattr_0.2.0.9000     xfun_0.49             cachem_1.1.0          jsonlite_1.8.9        progress_1.2.3       
[22] later_1.3.2           rayimage_0.11.0       parallel_4.3.0        prettyunits_1.2.0     R6_2.5.1              bslib_0.8.0           stringi_1.8.4        
[29] extrafontdb_1.0       pkgload_1.4.0         jquerylib_0.1.4       Rcpp_1.0.13-1         iterators_1.0.14      knitr_1.49            base64enc_0.1-3      
[36] extrafont_0.19        httpuv_1.6.15         timechange_0.3.0      tidyselect_1.2.1      rstudioapi_0.17.1     yaml_2.3.10           RcppSimdJson_0.1.12  
[43] doParallel_1.0.17     codetools_0.2-19      curl_6.0.0            processx_3.8.4        lattice_0.21-8        shiny_1.9.1           withr_3.0.2          
[50] evaluate_1.0.1        units_0.8-5           proxy_0.4-27          isoband_0.2.7         pillar_1.9.0          KernSmooth_2.23-20    foreach_1.5.2        
[57] googlePolylines_0.8.5 generics_0.1.3        mapiso_0.3.0          hms_1.1.3             munsell_0.5.1         scales_1.3.0          xtable_1.8-4         
[64] class_7.3-21          glue_1.8.0            clipr_0.8.0           tools_4.3.0           fs_1.6.5              rgl_1.3.12            grid_4.3.0           
[71] slippymath_0.3.1      Rttf2pt1_1.3.12       colorspace_2.1-1      cli_3.6.2             rappdirs_0.3.3        fansi_1.0.6           gtable_0.3.6         
[78] sass_0.4.9            digest_0.6.37         progressr_0.15.0      classInt_0.4-10       htmlwidgets_1.6.4     htmltools_0.5.8.1     lifecycle_1.0.4      
[85] httr_1.4.7            mime_0.12   
@apsteinmetz apsteinmetz added the bug Something isn't working label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant