Using tmap package for disease ecological mapping

Hello everyone!
I am new user of R programming. Therefore, before all things, I would like to apologize for my elementary and wordy questions!

Here is my Case:
I am using tmap package in Rstudio for disease ecological mapping using environmental factors in Ethiopia. The map is alrdeay classified in ArcGIS. I just wanted to creat an intercative webmap with it.

My Questions:

Q1. I tried to develop my webmap using tmap overlaying it on my existing national basemap in a way that layers don't cover one another. But I couldn't get that done, meaning layers are piled one over the other in which the top layer covers the one underneath. Hint: I used 'qtm()' instead of 'tm_shape()' to make it Hollow but at the same time I want to label them. However, qtm() sets the layer to NULL, which makes it impossible to label the features in the basemap to show where the disease exactly is in that admin. baoundry. I need your kind help on this!

Q2. How can we save an interactive html map having small multples columns using 'tmap_arrange()' command? Please take a look at the Qs below with thier respective code chanks.

Many thanks and kind regards!

My codes for Q1:

library(sp)
library(sf)
library(tmaptools)
library(tmap)
library(leaflet)
library(dplyr)
library(ggplot2)
library(rgdal)
library(ggthemes)
library(cartography)
library(tidyverse)

#Setting Working Directory----
setwd("C:/Users/Get_GFM-ITC/Desktop/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables")
getwd()

#Adding maps and data into R
Ethio_region <- st_read("C:/Users/Get_GFM-ITC/Desktop/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables/Ethio_region.shp", stringsAsFactors = FALSE)
Ethio_woreda <- st_read("C:/Users/Get_GFM-ITC/Desktop/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables/Ethio_Woreda_Final.shp", stringsAsFactors = FALSE)
class(Ethio_region)

Leishmap <- st_read("./Lieshmania_Risk_Final_30March21.shp", stringsAsFactors = FALSE)
head(Leishmap)#The first six rows of the data table
str(Leishmap)#Data structure
typeof(Leishmap)#Data type

tmap_mode("view")
FinalLesishmap2 <- tm_shape(Leishmap) +
tm_polygons("Leish_Risk", palette="Reds",
contrast=.7, id="Risk_level") +
tm_layout(main.title = "Leishmaniasis Risk Map",
main.title.position = "center", legend.outside =
FALSE)+
tm_scale_bar(position = "left", lwd = 1, color.dark
= "black", color.light = "white") +
tm_compass(type = "arrow", size = 3, position =
c("left", "top")) +

                 tm_shape(Ethio_woreda) +
                 tm_polygons(border.col = "black", 
                 id="W_NAME") + 
                 tm_layout(main.title = "Ethio_woreda", 
                 main.title.position = "center", legend.outside = 
                 FALSE)+
                 tm_scale_bar(position = "left", lwd = 1, color.dark 
                 = "black", color.light = "white") +
                 tm_compass(type = "arrow", size = 3, position = 
                 c("left", "top")) +
                 #tm_add_legend(type = "fill", col = "white", labels 
                  = "Ethio_Woredas") +

                 tm_shape(Ethio_region) +
                 tm_polygons(border.col = "red", 
                 id="REG_NAME") +
                 tm_fill() +
                 tm_layout(main.title = "Ethio_region", main.title.position = "center", legend.outside = FALSE)+
                 tm_scale_bar(position = "left", lwd = 1, color.dark = "black", color.light = "white") +
                 tm_compass(type = "arrow", size = 3, position = c("left", "top")) 

FinalLesishmap2

My codes for Q2:

library(rgdal)
library(raster)
library(sp)# classes for spatial data
library(sf)# creates simple feature
library(tmaptools)
library(tmap)thematic mapper
library(leaflet)
library(dplyr)
library(ggplot2)
library(ggthemes)
library(tidyverse)#collection of R packages for Data science, it reads in tibble
library(tidytools)

setwd("D:/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables")

#Adding maps and data into R
Ethio_region <- st_read("D:/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables/Ethio_region.shp", stringsAsFactors = FALSE)
Ethio_woreda <- st_read("D:/AHRI/VL_Analysis_Final/Practice_Geti/Deliverables/Ethio_Woreda_Final.shp", stringsAsFactors = FALSE)
Leishmap <- st_read("./Lieshmania_Risk_Final_30March21.shp", stringsAsFactors = FALSE)

tmap_mode("view")
Q1 <- tm_shape(Ethio_woreda) +
tm_polygons(border.col = "red", id="W_NAME") +
tm_layout(title = "Ethio_woreda", main.title.position = "center", legend.outside = FALSE) +
tm_scale_bar(position = "left", lwd = 1, color.dark = "black", color.light = "white") +
tm_compass(type = "arrow", size = 3, position = c("left", "top")) +
tm_add_legend(type = "fill", col = "white", labels = "Ethio_Woredas")

Q2 <- tm_shape(Ethio_region) +
tm_polygons(border.col = "red", id="REG_NAME") +
tm_layout(title = "Ethio_region", main.title.position = "center", legend.outside = FALSE) +
tm_scale_bar(position = "left", lwd = 1, color.dark = "black", color.light = "white") +
tm_compass(type = "arrow", size = 3, position = c("left", "top"))

Q3 <- tm_shape(Leishmap) +
tm_polygons("Leish_Risk",title = "Risk Level", palette="Reds", contrast=.7, id="Risk_level") +
tm_layout(title = "Leishmaniasis Risk Classified Based on Environmental Factors", main.title.position = "center", legend.outside = FALSE)+
tm_scale_bar(position = "right", lwd = 1, color = "black", color.light = "white") +
tm_compass(type = "arrow", size = 3, position = c("left", "top"))

Webmap_trial1 <- tmap_arrange(Q3, Q2, Q1, widths = c(.25, .75))

#Saving the maps----
tmap_save(Webmap_trial1, "Webmap_trial1.html")

###This is what I got in the console while saving the interactive map:

#Saving the maps----

tmap_save(Webmap_trial1, "Webmap_trial1.html")
Compass not supported in view mode.
Compass not supported in view mode.
Compass not supported in view mode.
Error: Unable to save the interactive map. Note that saving interactive small multiples is not supported yet. The error message from htmlwidgets::saveWidget is

Please folks, I need your kind response asap.
With thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.