1

Is it possible to create figure labels, and reference them within text, for interactive tmap objects in a R markdown that will be rendered/hosted using shiny runtime to make an interactive document? In a regular markdown report for a static map I use something like this

{r DIST-MAP, echo=FALSE, fig.cap="Caribou distribution in British Columbia", fig.width=7, message=FALSE, warning=FALSE, out.width="100%", fig.asp=1, fig.align='center'}

knitr::include_graphics(auto_pdf = F, path = "./data/RATA_DIST_MAP.png")

and reference it using : \@ref(fig:DIST-MAP)

However when I use

{r DIST-MAP, echo=FALSE, fig.align='center', fig.cap="Caribou distribution in British Columbia", message=FALSE, warning=FALSE, out.width="100%"}


tmap_mode("view") 

tmap_options(basemaps = c("OpenTopoMap", "Esri.WorldImagery"))

tm_shape(ALL_HERDS , name="Caribou Herds") +
  tm_fill(alpha = 0.5, id = "HERD_NAME", col= "ECO_GROUP", palette = "viridis") +
  tm_borders(lwd = 4, col = "black") +
  tm_text(text ="HERD_NAME", auto.placement  = T , size = 3/4)+
  tm_basemap()

The object/figure is not labelled or referenced in the rendered document. Is it possible to label refernce interactive objects similar to static figures?

BEVAN
  • 426
  • 2
  • 12

0 Answers0