Tmap: error in view mode

Created on 19 Jul 2019  路  10Comments  路  Source: mtennekes/tmap

I'm getting this in one of the sf vignettes:

library(sf)
dem(nc, echo = FALSE)
tmap_mode("view")
# tmap mode set to interactive viewing
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
# Error in as.hexmode(strsplit(lty, "")[[1]]) : 
#    'x' cannot be coerced to class "hexmode"

it runs fine in "plot" mode.

bug

Most helpful comment

I had to access the tmap package from the development site rather than from CRAN to load version 2.3-1
Once I installed the new version and restarted R Studio, all was working once again.

https://www.displayr.com/installing-r-packages-from-github/

install.packages("devtools")

library(devtools)
install_github("tmap")

library(tmap)

This process can also be completed in the console.

All 10 comments

Thanks! Fixed, please reopen if necessary.

Thanks for the quick fix, @mtennekes !

I'm getting this in one of the sf vignettes:

library(sf)
dem(nc, echo = FALSE)
tmap_mode("view")
# tmap mode set to interactive viewing
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
# Error in as.hexmode(strsplit(lty, "")[[1]]) : 
#    'x' cannot be coerced to class "hexmode"

it runs fine in "plot" mode.

I am seeing the same error. Can you please provide a bit more detail about the running in "plot" mode work around? My maps are in a Shiny App

Thank you!

Map <- tm_shape(MyMap)+
tm_fill(col="fillCol",
title = " ",
palette = MyColors)+
tm_shape(localMap)+
tm_borders(col = "white")+
tm_layout("My Title", legend.text.size = -0.5)+
tm_text(text = "Name", size = 0.5, group = "Site Names")

Map %>%  tmap_leaflet() %>% 
  setView(lng = -105.10033, lat = 39.6, zoom =9) %>%
  addProviderTiles('Esri.WorldGrayCanvas', group='Grayscale Map') %>% 
  addProviderTiles('OpenStreetMap', group='Street Map') %>%
  addMarkers(lng = -105.155927, 
             lat = 39.746347, 
             icon = YellowIcon, 
             label = "Site", 
             popup = "<b>Program type:</b><br>Ext. Day", 
             popupOptions = labelOptions(direction = "bottom",
                                         textsize = "8px"))

Error in as.hexmode(strsplit(lty, "")[[1]]) :
'x' cannot be coerced to class "hexmode"

I'm still having this issue, with my own code:

tmap_mode("view")
svi_bg <- tm_shape(chicago_svi) + tm_fill("R_PL_THEME1", style = "Blues")
Error in as.hexmode(strsplit(lty, "")[[1]]) : 
'x' cannot be coerced to class "hexmode"

I've tried redownloading tmaps and leaflet, and I still get this message. Map works perfectly well in plot mode. Any ideas?

I had to access the tmap package from the development site rather than from CRAN to load version 2.3-1
Once I installed the new version and restarted R Studio, all was working once again.

https://www.displayr.com/installing-r-packages-from-github/

install.packages("devtools")

library(devtools)
install_github("tmap")

library(tmap)

This process can also be completed in the console.

thanks!!

For me, install_github("tmap") returned error "Error in parse_repo_spec(repo) : Invalid git repo specification: 'tmap'".

install_github("mtennekes/tmap") worked fine, & once installed tmap_mode("view") was working again.

Allison, Did you restart your computer/R Studio?

not after installing from GitHub, is that what you mean?

Yes, I had to restart my computer (thus restarting R). Good Luck

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Robinlovelace picture Robinlovelace  路  4Comments

Si-Chong picture Si-Chong  路  4Comments

jarsc568 picture jarsc568  路  8Comments

Nowosad picture Nowosad  路  5Comments

Nowosad picture Nowosad  路  5Comments