我在尝试使用 rnaturalearth
包提取大湖数据时收到错误消息。我已经使用相同的代码一段时间了,直到今天才收到错误。我不确定该网站是否已关闭,但这种情况已经持续了几周了。我posted on their github但尚未收到回复。其他人可以复制此错误或知道如何解决它或获取相同数据的解决方法吗?
install.packages('rnaturalearth','sf')
lakes <- rnaturalearth::ne_download(scale = 110,
type = 'lakes',
category = 'physical') %>%
sf::st_as_sf(lakes110, crs = 4269) %>% filter(name_alt =="Great Lakes")
错误消息:
trying URL 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_lakes.zip'
Error in utils::download.file(file.path(address), zip_file <- tempfile()) :
cannot open URL 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_lakes.zip'
In addition: Warning message:
In utils::download.file(file.path(address), zip_file <- tempfile()) :
cannot open URL 'https://www.naturalearthdata.com/http/www.naturalearthdata.com/download/110m/physical/ne_110m_lakes.zip': HTTP status was '404 Not Found'
最佳答案
我最近遇到了同样的问题,并使用以下代码获取了世界上所有湖泊的高分辨率形状文件:
library(sf)
url <- paste0("https://www.naturalearthdata.com/",
"http//www.naturalearthdata.com/download/10m/physical/",
"ne_10m_lakes.zip")
path <- tempdir()
download.file(url, paste0(path, "/lakes.zip"))
unzip(paste0(path, "/lakes.zip"))
lakes <- read_sf("ne_10m_lakes.shp")
例如,以下是用于绘制五大湖的数据:
library(ggplot2)
ggplot(lakes) +
geom_sf(fill = "lightblue") +
coord_sf(xlim = c(-100, -75), ylim = c(40, 50)) +
theme(panel.background = element_rect(fill = '#d0d890'),
panel.grid = element_line(color = '#00000010'))
关于r - 无法使用 sf() 和 rnaturalearth() 在 R 中提取湖泊几何数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75149027/