小编nni*_*loc的帖子

无法在 R 中读取 shp 文件

我尝试使用以下代码在 Mac 上打开一个 shp 文件:

library(tidyverse)
library(sf)
library(rgeos)
sf_trees_raw <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-01-28/sf_trees.csv')
temp_shapefile <- tempfile()
download.file("https://www2.census.gov/geo/tiger/TIGER2017//ROADS/tl_2017_06075_roads.zip", temp_shapefile)
sf_roads <- unzip(temp_shapefile, "tl_2017_06075_roads.shp") %>%
  read_sf()
Run Code Online (Sandbox Code Playgroud)

但我收到此错误消息:

Error: Cannot open "/Users/name/Documents/Playground/Trees_SF/tl_2017_06075_roads.shp"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.
Run Code Online (Sandbox Code Playgroud)

我尝试了其他 shp 文件,但收到相同的错误消息:

map <- read_sf("per_admbnda_adm1_2018.shp")
Error: Cannot open "/Users/name/Documents/Playground/Trees_SF/per_admbnda_adm1_2018.shp"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.
Run Code Online (Sandbox Code Playgroud)

我尝试复制 shx 和 dbf 文件,但没有解决问题。

任何帮助将不胜感激。

r r-sf

3
推荐指数
1
解决办法
2940
查看次数

标签 统计

r ×1

r-sf ×1