r-tmap/tmap

tmap.deckgl is born

Opened this issue · 5 comments

See https://github.com/r-tmap/tmap.deckgl

It's only a start, and mainly serves as a proof of concept for the extendibility of tmap.

remotes::install_github("r-tmap/tmap")
remotes::install_github("r-tmap/tmap.deckgl")

library(tmap)
library(tmap.deckgl)

tmap_mode("deck")
tm_shape(World) + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "RdYlGn"))
Screenshot 2024-04-19 at 14 18 31

Help is welcome, especially from those who know deck.gl.

As a second proof of concept, I will add a new 3d layer type, probably called tm_polygons3D.

Hi @mtennekes -- I was unable to reproduce this example (after installing everything):

library(tmap)
library(tmap.deckgl)

tmap_mode("deck")
#> tmap mode set to 'deck'
tm_shape(World) + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "RdYlGn"))
#> Error in tmapDeckGLCompPrepare(comp = structure(list(show = TRUE, design = "standard", : could not find function "tmapDeckGLCompPrepare"

Same here, I get the same error!

Also, FWIW, @mtennekes et al. I know tmap.deckgl is meant as a POC for extending tmap, but I am currently working on (basically just started) implementing deck.gl-leaflet either as a standalone package or as part of leafgl. First POC shows that it is able to handle large amounts of points (haven't tested lines and polygons yet).

I just want to mention this here, as it has the advantage of not having to implement a completely new rendering environment (i.e. deckgl) but seems to play nicely with all the existing leaflet functionality. Though, this also means that things like extruded polygons won't make sense probably, as leaflet maps cannot be tilted...

Screenshot shows 1M points, behaving very smoothly

image

How do people feel about this? Should this be part of leafgl or be its own dedicated package?

It's working now r-tmap/tmap.deckgl@0d59c9e (had to export a lot of internal methods)

Thanks @tim-salabim awesome developments!

How do people feel about this? Should this be part of leafgl or be its own dedicated package?

With 'own dedicated package' do you mean your just-started leaflet integration with deck.gl or the deckgl package? If the former, I don't have a strong opinion whether to have it a new package or part of leafgl.

From a tmap perspective:

  • For 2d maps, the deckgl-leaflet integration would be superior to the current leaflet layer methods, or are there any downsides? E.g. can all visual variables be encoded feature-wise, like stroke width and type? If so, these will eventually be replace the current leaflet layer methods in "view" mode.
  • I would love to have a 3d rendering mode. Just as a POC, I will add tm_polygons3D to tmap.deckgl.

I am also looking at rayshader route for 3d maps. If someone has low-level demo scripts how to create choropleths (without using ggplot2 because I'm still not familiar with the ggplot2 internals, so it's hard for me to reuse rayshader::plot_gg), most welcome.

I've just started to add it to leafgl, mainly so I don't have to copy over all the helpers to a new package. I'll keep you updated on how things go. I will test all feature-wise mappings as well.

Interested in exploring the functionality, but returning unused argument (prx = list()) with the example


> tmap_mode("deck")
tmap mode set to 'deck'

> tm_shape(World) + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "RdYlGn"))
[cols4all] color palettes: use palettes from the R package cols4all. Run 'cols4all::c4a_gui()' to explore them. The old palette name "RdYlGn" is named "rd_yl_gn" (in long format "brewer.rd_yl_gn")
Error in tmapDeckGLInit(o = list(modes = list(plot = list(name = "Grid",  : 
  unused argument (prx = list())

> tm_shape(World) + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "rd_yl_gn"))
Error in tmapDeckGLInit(o = list(modes = list(plot = list(name = "Grid",  : 
  unused argument (prx = list())