【问题标题】:Object 'world' not found找不到对象“世界”
【发布时间】:2021-03-24 03:18:17
【问题描述】:

我只是尝试使用以下在线代码在我的研究区域上绘制地图,但即使使用在线代码,它也会出现以下错误:

**install.packages(c("cowplot","googleway", "ggplot2", "ggrepel",
                   "ggspatial", "libwgeom", "sf", "rnaturalearth", "rnaturalearthdata"))                 
library("ggplot2")  
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)**

st_as_sfc.SpatialPolygons(sp::geometry(x), ...) 中的错误: 查找哪个孔属于哪个外环所需的包 rgeos

类(世界) 错误:找不到对象“世界”

我不知道是什么导致了这个错误,因为我是 R 新手。 任何建议将不胜感激

【问题讨论】:

  • 同时安装rgeos 包。这就是第一个错误告诉您的内容。
  • @MrFlick 你是完全正确的。在包中包含 rgeos 解决了这个问题。感谢您的回复。谢谢

标签: r


【解决方案1】:

你只需要安装 rgeos 包并加载它

install.packages(c("cowplot","googleway", "ggplot2", "ggrepel",
               "ggspatial", "libwgeom", "sf", "rnaturalearth", "rnaturalearthdata", 
"rgeos"))                 
library("ggplot2")  
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
library(rgeos)
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)

**

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 2014-02-24
    • 2013-02-04
    相关资源
    最近更新 更多