mapview icon indicating copy to clipboard operation
mapview copied to clipboard

All background maps are blank.

Open ojlise opened this issue 3 years ago • 3 comments

When plotting data on mapview in R, the data points show up, but the background maps do not. I am behind a firewall so I have to use a proxy to get the data. Do I have to set up something similar to be able to load the background maps?

I'm suspecting that the loading of the maps are being stopped by the firewall.

So I end up with a bunch of dots on a blank background.

ojlise avatar Sep 29 '22 19:09 ojlise

I'm having the same issue here with both sf and sp object types. However, I can load a map using breweries just fine. So, likely something with how I'm formatting my data... Example data and code:

#Load packages
library(tidyverse)
library(sf)
#Create example data
latitude = c(44.10606, 44.10668, 43.69781, 43.58378, 43.83922, 43.84134)
longitude = c(-124.0897, -124.0890, -122.0458, -122.7138, -122.5581, -122.5467)
#Make spatial dataframe
data = data.frame(latitude, longitude) %>%
  st_as_sf(coords = c('longitude', 'latitude'))
#Generate map (without basemap)
mapview(data)

I am using R v. 4.2.2 in RStudio v. 2022.2.04 on Mac OSX v. 10.15.7. I'm using mapview v. 2.11.0, sf v. 1.0-9, sp v. 1.6-0.

hrdawson avatar Jan 28 '23 03:01 hrdawson

I have found that this just happens within the Rstudio viewer pane and again on a corporate network so it could be something blocking the Viewwer pane from calling urls. A workaround is to click the icon to view the map in a new window which opns it in a browser. from memory the Rstudio Viewer is a type of browser (within a web app which is what Rstudio is) MicrosoftTeams-image (3) MicrosoftTeams-image (4)

adam-gruer avatar Jul 31 '23 22:07 adam-gruer

I found that mapview has a problem loading the background map when the sf points do not have a CRS.

library(sf)
library(mapview)
library(tidyverse)


data(breweries)
mapview(breweries)

# Works fine, plots points with OSM background map


points <- data.frame(pt.names = letters[1:3],
                     lats = c(34, 35, 36),
                     longs = c(-110, -111, -112))

points %>%
  st_as_sf(coords = c("longs", "lats")) %>%
  mapview()

# plots points without background map

points %>%
  st_as_sf(coords = c("longs", "lats")) %>%
  mapview(crs = 4381)

# Also plots points without background map



points %>%
  st_as_sf(coords = c("longs", "lats"),
           crs = 4381) %>%
  mapview()

# Plots points with background map

So maybe the problem is with the CRS substitution?

sessionInfo()
R Under development (unstable) (2024-03-18 r86148)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.6.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
 [1] mapview_2.11.2   sf_1.0-16        lubridate_1.9.3  forcats_1.0.0    stringr_1.5.1   
 [6] purrr_1.0.2      readr_2.1.5      tidyr_1.3.1      tibble_3.2.1     tidyverse_2.0.0 
[11] dartR_2.9.7      dartR.data_1.0.2 dplyr_1.1.4      ggplot2_3.5.0    adegenet_2.1.10 
[16] ade4_1.7-22     

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3      jsonlite_1.8.8          rstudioapi_0.15.0      
  [4] magrittr_2.0.3          farver_2.1.1            fs_1.6.3               
  [7] fields_15.2             vctrs_0.6.5             memoise_2.0.1          
 [10] SNPRelate_1.37.1        mmod_1.3.3              base64enc_0.1-3        
 [13] terra_1.7-71            usethis_2.2.3           htmltools_0.5.7        
 [16] curl_5.2.1              raster_3.6-26           KernSmooth_2.23-22     
 [19] desc_1.4.3              htmlwidgets_1.6.4       plyr_1.8.9             
 [22] cachem_1.0.8            igraph_2.0.3            mime_0.12              
 [25] lifecycle_1.0.4         iterators_1.0.14        pkgconfig_2.0.3        
 [28] gap_1.5-3               Matrix_1.6-5            R6_2.5.1               
 [31] fastmap_1.1.1           rbibutils_2.2.16        shiny_1.8.1            
 [34] digest_0.6.35           colorspace_2.1-0        GGally_2.2.1           
 [37] ps_1.7.6                patchwork_1.2.0         leafem_0.2.3           
 [40] pkgload_1.3.4           crosstalk_1.2.1         vegan_2.6-4            
 [43] fansi_1.0.6             timechange_0.3.0        gdistance_1.6.4        
 [46] gdata_3.0.0             mgcv_1.9-1              compiler_4.4.0         
 [49] remotes_2.5.0           proxy_0.4-27            bit64_4.0.5            
 [52] withr_3.0.0             doParallel_1.0.17       DBI_1.2.2              
 [55] RgoogleMaps_1.5.1       ggstats_0.6.0           pkgbuild_1.4.4         
 [58] R.utils_2.12.3          maps_3.4.2              MASS_7.3-60.2          
 [61] sessioninfo_1.2.2       leaflet_2.2.2           classInt_0.4-10        
 [64] gtools_3.9.5            permute_0.9-7           gdsfmt_1.39.1          
 [67] tools_4.4.0             units_0.8-5             ape_5.7-1              
 [70] httpuv_1.6.15           R.oo_1.26.0             glue_1.7.0             
 [73] satellite_1.0.5         callr_3.7.5             nlme_3.1-164           
 [76] promises_1.2.1          grid_4.4.0              cluster_2.1.6          
 [79] reshape2_1.4.4          memuse_4.2-3            generics_0.1.3         
 [82] seqinr_4.2-36           leaflet.providers_2.0.0 gtable_0.3.4           
 [85] tzdb_0.4.0              R.methodsS3_1.8.2       class_7.3-22           
 [88] pinfsc50_1.3.0          dismo_1.3-14            data.table_1.15.2      
 [91] hms_1.1.3               sp_2.1-3                utf8_1.2.4             
 [94] foreach_1.5.2           pillar_1.9.0            vroom_1.6.5            
 [97] spam_2.10-0             servr_0.30              later_1.3.2            
[100] splines_4.4.0           lattice_0.22-6          bit_4.0.5              
[103] PopGenReport_3.1        tidyselect_1.2.1        genetics_1.3.8.1.3     
[106] miniUI_0.1.1.1          knitr_1.45              gridExtra_2.3          
[109] stats4_4.4.0            xfun_0.42               devtools_2.4.5         
[112] stringi_1.8.3           codetools_0.2-19        cli_3.6.2              
[115] xtable_1.8-4            Rdpack_2.6              jquerylib_0.1.4        
[118] processx_3.8.4          munsell_0.5.0           vcfR_1.15.0            
[121] Rcpp_1.0.12             pegas_1.3               png_0.1-8              
[124] StAMPP_1.6.3            parallel_4.4.0          ellipsis_0.3.2         
[127] dotCall64_1.1-1         profvis_0.3.8           calibrate_1.7.7        
[130] gap.datasets_0.0.6      urlchecker_1.0.1        viridisLite_0.4.2      
[133] mvtnorm_1.2-5           scales_1.3.0            e1071_1.7-14           
[136] crayon_1.5.2            combinat_0.0-8          rlang_1.1.3

alexkrohn avatar Aug 14 '24 14:08 alexkrohn