使用调色板和不同数据集的TMAP

发布于 2025-01-26 02:27:01 字数 462 浏览 5 评论 0原文

我想创建一个调色板,我的目标是按照该国拥有多少米的成绩为国家着色。我该怎么做?

这是我的数据集:

'

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)

'

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)

'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日记撕了你也走了 2025-02-02 02:27:01

您使用的数据集由点而不是多边形组成,因此没有边界或填充物可绘制。如果您想根据计数绘制这些点,则可以做:

data(metro)

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

”在此处输入图像说明”

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文