无法在 tempdir() 中打开 GitHub shapefile
Cannot open GitHub shapefile in tempdir()
我想通过 GitHub 下载打开 *zip
格式的 shapefile,但在 windows 10 中没有成功。在我的示例中:
library(rgdal)
# get AOI
download.file(
"https://github.com/Leprechault/trash/blob/main/stands_example.zip",
zip_path <- tempfile(fileext = ".zip")
)
unzip(zip_path, exdir = tempdir())
Warning message:
In unzip(zip_path, exdir = tempdir()) :
error 1 extracting from zip file
setwd(tempdir())
stands_extent <- readOGR(file.path(tempdir(), "stands_target")) # Border
Error in ogrListLayers(dsn = dsn) : Cannot open data source
dir()
[1] "file9e88423c5c2b.zip" "rs-graphics-5776e6df-be67-40c4-a4f7-e311eb11d978"
请问有什么帮助解决这个问题吗?
library(rgdal)
# get AOI
download.file(
"https://github.com/Leprechault/trash/raw/main/stands_example.zip",
zip_path <- tempfile(fileext = ".zip")
)
unzip(zip_path, exdir = tempdir())
setwd(tempdir())
stands_extent <- readOGR(".", "stands_target")
OGR data source with driver: ESRI Shapefile
Source: "C:\Users\fores\AppData\Local\Temp\RtmpGSHaOM", layer: "stands_target"
with 7 features
It has 2 fields
我想通过 GitHub 下载打开 *zip
格式的 shapefile,但在 windows 10 中没有成功。在我的示例中:
library(rgdal)
# get AOI
download.file(
"https://github.com/Leprechault/trash/blob/main/stands_example.zip",
zip_path <- tempfile(fileext = ".zip")
)
unzip(zip_path, exdir = tempdir())
Warning message:
In unzip(zip_path, exdir = tempdir()) :
error 1 extracting from zip file
setwd(tempdir())
stands_extent <- readOGR(file.path(tempdir(), "stands_target")) # Border
Error in ogrListLayers(dsn = dsn) : Cannot open data source
dir()
[1] "file9e88423c5c2b.zip" "rs-graphics-5776e6df-be67-40c4-a4f7-e311eb11d978"
请问有什么帮助解决这个问题吗?
library(rgdal)
# get AOI
download.file(
"https://github.com/Leprechault/trash/raw/main/stands_example.zip",
zip_path <- tempfile(fileext = ".zip")
)
unzip(zip_path, exdir = tempdir())
setwd(tempdir())
stands_extent <- readOGR(".", "stands_target")
OGR data source with driver: ESRI Shapefile
Source: "C:\Users\fores\AppData\Local\Temp\RtmpGSHaOM", layer: "stands_target"
with 7 features
It has 2 fields