Tmap using palette and different dataset

Viewed 64

I would like to create a palette, my goal is to color the countries in proportion to how many meters they have in that country. How can I do it?

This is my dataset:

'

library(readxl)
library(sf)
library(raster)
library(dplyr)
library(spData)
library(spDataLarge)
library(tmap)    # for static and interactive maps
library(leaflet) # for interactive maps
library(ggplot2) # tidyverse data visualization package

mt <- data(metro)

metro %>% count(iso_a3)

map = tm_shape(world) + tm_fill() + tm_borders()

print(map)

'

1 Answers

The data set you are using is composed of points rather than polygons, so there are no borders or fills to draw. If you want to plot the points according to the counts, you can do:

data(metro)

metro %>% count(iso_a3) %>% tm_shape() + tm_bubbles(col = "n")

enter image description here

Related