更改栅格图中的变量标签/传说以离散字符

发布于 2025-02-13 16:37:04 字数 396 浏览 0 评论 0原文

我刚刚使用栅格数据制作了一个图,该栅格数据由6种不同的土地类型组成,并将其适合多边形向量。我试图将连续比例​​尺(1-6)上的值更改为每个不同颜色所代表的每个LandType(例如草原,城市等)的名称。我尝试插入休息时间,但是传说中的每个框都包含标签(1-2、2-3、3-4等) 栅格图,其中每个差异颜色代表diff land类型

这是我的代码: rasterxpolygonplotcode

I have just made a plot using raster data that consists of 6 different land types and fit them to polygon vectors. I'm trying to change the values on the continuous scale bar (1-6) to the names of each landtype (e.g. grasslands, urban, etc) which is what each different colour represents. I have tried inserting breaks, however then each box in the legend contains labels (1-2, 2-3, 3-4 etc.)
Raster plot where each diff colour represents diff land type

This is my code:
rasterxpolygonplotcode

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

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

发布评论

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

评论(1

霞映澄塘 2025-02-20 16:37:04

示例数据

library(terra)
r <- rast(nrows=10, ncols=10)
values(r) <- sample(3, ncell(r), replace=TRUE)
cover <- c("forest", "water", "urban")

您可以执行的

plot(r, type="classes", levels=cover)

:或首先将栅格分类

levels(r) <- data.frame(id=1:3, cover=c("forest", "water", "urban"))
plot(r)

Example data

library(terra)
r <- rast(nrows=10, ncols=10)
values(r) <- sample(3, ncell(r), replace=TRUE)
cover <- c("forest", "water", "urban")

You can either do:

plot(r, type="classes", levels=cover)

Or first make the raster categorical

levels(r) <- data.frame(id=1:3, cover=c("forest", "water", "urban"))
plot(r)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文