英文:
Latest / Current Worldmap as of 2023
问题
请问有人能够向我指出目前推荐的绘制世界地图的解决方案吗?(我之前一直在使用rworldmap
(通过maptools
、rgdal
和rgeos
已被淘汰),并在raster
上取得了一些进展(建议使用terra
),但它们都告诉我它们本身或依赖于过时的软件包,并将很快消失。因此,大多数stackoverflow上的解决方案都已过时。)
简单的起步需求。(考虑世界温度和温度异常。)
绘制一个带有大陆或国家的世界地图,然后在其上绘制数据值。有时我的数据以(国家,值)的形式存在,有时我的数据以(纬度,经度,值)的网格点形式存在(也希望能对其进行平滑处理)。颜色方案为红到绿或红到蓝。理想情况下,还可以选择地图投影和纬度/经度线的选项。就是这样。
我需要类似于小册或入门示例的东西。指引将不胜感激。
英文:
Could someone please point me to the current recommended solution for plotting world maps? (I have been using rworldmap
(obsoletes via maptools
, rgdal
, and rgeos
) and made some progress on raster
(suggests terra
), but both are telling me that they are themselves or that they rely on legacy packages, and will go away soon. Most solutions on stackoverflow are therefore going out of date.)
Simple starter needs. (Think world temperatures and temperature anomaly.)
Plot a worldmap with continents or countries, and then plot data values over them. I sometimes have data values by (countries,value), I sometimes have data values as (lat,lon,value) grid points (which would be nice to be smoothed, too). Color scheme red to green or red to blue. Ideally, also a choice of map projection and option for latitude/longitude lines. That's it.
I need something like a vignette or starter examples. Pointers would be greatly appreciated.
答案1
得分: 2
以下是您要的翻译内容:
您在一个问题中提出了许多问题,但这是如何使用 terra/geodata 获取国家边界的方法。
```R
library(geodata)
w <- world(path=".")
plot(w)
points(cbind(c(0, 10), c(0, 10)), col="red", cex=2, pch=20)
w
是一个SpatVector,如“terra”包中所定义。
这里有两种制作更精美地图的方法(使用基本绘图和ggplot)。并且这是一个简短的教程。
您还可以使用“sf”包。如果您正在使用 w
,您首先需要执行以下操作:
library(sf)
wsf <- st_as_sf(w)
<details>
<summary>英文:</summary>
You are asking many questions in one, but here is how you can get country boundaries using terra/geodata
library(geodata)
w <- world(path=".")
plot(w)
points(cbind(c(0, 10), c(0, 10)), col="red", cex=2, pch=20)
`w` is a SpatVector, as defined in the "terra" package.
Here are [two approaches][1] to making more fancy maps (with base plot and ggplot). And here is a short [tutorial][2].
You can also use the "sf" package. If you were using `w` you would first need to do
library(sf)
wsf <- st_as_sf(w)
[1]: https://stackoverflow.com/questions/74564294/r-ggplot-plotting-map-raster-with-rounded-shape-how-to-remove-data-outside-pro/74566254#74566254
[2]: https://rspatial.org/spatial/9-maps.html
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论