r-spatial / mapview

Interactive viewing of spatial data in R
https://r-spatial.github.io/mapview/
GNU General Public License v3.0
510 stars 91 forks source link

Rasters without CRS not displayed #268

Open michaeldorman opened 4 years ago

michaeldorman commented 4 years ago

Seems like rasters without a CRS definition are not displayed. Although hovering with the mouse shows pixel values, the raster is completely transparent. Here is a reproducible example:

library(mapview)
library(raster)

# This works fine
x = plainview::poppendorf[[5]]
mapview(x)

unnamed-chunk-1-1

# This shows an empty map...
proj4string(x) = NULL
mapview(x)

unnamed-chunk-1-2

P.S. Thanks for the great and very useful package!

tim-salabim commented 4 years ago

Thanks, you're right. This should actually invoke plainview::plainView to show the raster, not leaflet. I'll look into it soon.

michaeldorman commented 4 years ago

Great, thanks! Didn't know about plainview::plainView, will use that for now.

michaeldorman commented 4 years ago

plainView doesn't seem to display raster values on hover though, if it's possible this could be a very useful feature

tim-salabim commented 4 years ago

Oh yes it would! All the JS stuff is growing a little over my head (a literal translation from German :-) ), though I guess it would actually be easier than for leaflet becuase we don't have to worry about projections...

tim-salabim commented 4 years ago

@michaeldorman what's your packageVersion("mapview")? Mine is 2.7.7 and things work fine... See bottom-left in the image below.

Screenshot from 2020-02-25 18-50-02

michaeldorman commented 4 years ago

I have mapview version 2.7.0. With devtools::install_github("r-spatial/mapview") version 2.5.0 is installed, which gives the same result. I also tried devtools::install_github("r-spatial/mapview@develop") but the installation doesn't succeed:

Screenshot from 2020-02-25 22-22-05

tim-salabim commented 4 years ago

Can you try to first remotes::install_github("r-spatial/leafem") and then install the develop branch of mapview again? That should resolve things.

michaeldorman commented 4 years ago

Thanks, it didn't solve the issue...

My session info is:

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

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=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] raster_3.0-12 sp_1.4-0      mapview_2.7.7

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3              compiler_3.6.2          later_1.0.0            
 [4] R.methodsS3_1.7.1       R.utils_2.8.0           iterators_1.0.10       
 [7] gdalUtils_2.0.1.14      base64enc_0.1-3         class_7.3-15           
[10] tools_3.6.2             digest_0.6.25           jsonlite_1.6.1         
[13] satellite_1.0.2         lifecycle_0.1.0         lattice_0.20-38        
[16] viridisLite_0.3.0       png_0.1-7               rlang_0.4.4            
[19] foreach_1.4.4           shiny_1.4.0             DBI_1.1.0              
[22] crosstalk_1.0.0         yaml_2.2.1              rgdal_1.4-4            
[25] fastmap_1.0.1           e1071_1.7-3             leaflet.providers_1.9.0
[28] htmlwidgets_1.5.1       webshot_0.5.2           stats4_3.6.2           
[31] classInt_0.4-2          leaflet_2.0.3           grid_3.6.2             
[34] sf_0.8-1                R6_2.4.1                plainview_0.1.0        
[37] farver_2.0.3            magrittr_1.5            scales_1.1.0           
[40] codetools_0.2-16        promises_1.1.0          htmltools_0.4.0        
[43] units_0.6-5             mime_0.9                xtable_1.8-4           
[46] colorspace_1.4-1        httpuv_1.5.2            KernSmooth_2.23-16     
[49] munsell_0.5.0           leafem_0.1.0            R.oo_1.23.0            
tim-salabim commented 4 years ago

Hm.. strange! I cannot reproduce your issue. Here's my sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 18.04 LTS

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=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] mapview_2.7.7   plainview_0.1.0 raster_3.0-12   sp_1.3-1       

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3         lattice_0.20-35    prettyunits_1.0.2  png_0.1-7         
 [5] class_7.3-14       ps_1.3.0           assertthat_0.2.1   rprojroot_1.3-2   
 [9] digest_0.6.20      packrat_0.5.0      foreach_1.4.4      mime_0.7          
[13] R6_2.4.1           backports_1.1.4    stats4_3.6.1       e1071_1.7-3       
[17] rlang_0.4.4        rstudioapi_0.10    callr_3.3.1        R.utils_2.9.0     
[21] R.oo_1.22.0        desc_1.2.0         devtools_2.1.0     rgdal_1.4-4       
[25] webshot_0.5.1      htmlwidgets_1.5.1  munsell_0.5.0      shiny_1.4.0       
[29] compiler_3.6.1     httpuv_1.5.2       base64enc_0.1-3    pkgbuild_1.0.3    
[33] htmltools_0.4.0    codetools_0.2-15   fansi_0.4.1        viridisLite_0.3.0 
[37] crayon_1.3.4       withr_2.1.2        later_1.0.0        sf_0.8-1          
[41] R.methodsS3_1.7.1  grid_3.6.1         jsonlite_1.6       satellite_1.0.1   
[45] xtable_1.8-4       DBI_1.1.0          magrittr_1.5       units_0.6-5       
[49] scales_1.0.0       KernSmooth_2.23-15 cli_2.0.1          fs_1.3.1          
[53] promises_1.1.0     remotes_2.1.0      leaflet_2.0.3      testthat_2.2.1    
[57] iterators_1.0.12   tools_3.6.1        gdalUtils_2.0.1.14 leafem_0.1.0      
[61] glue_1.3.1         crosstalk_1.0.0    processx_3.4.1     pkgload_1.0.2     
[65] fastmap_1.0.1      yaml_2.2.0         colorspace_1.4-1   sessioninfo_1.1.1 
[69] classInt_0.4-2     memoise_1.1.0      usethis_1.5.1   
tim-salabim commented 4 years ago

That said, I can reproduce the issue on my windows machine. I will try to figure out what's going on tomorrow when I'm back at work

michaeldorman commented 4 years ago

Thank you for the help! I'll use plainView for now