[英]Cannot load a shapefile in R “Error: no features found”
我正在嘗試閱讀可以使用此url下載的shapefile。
我有一個類似於下一個的代碼,可以自動下載文件:
library("raster")}
url<-"http://www6.gipuzkoa.eus/CATASTRO/Planos/ZIP-A098.zip"
downloader::download(url, dest=paste0(getwd(),"/","my_file.zip"), mode="wb",quiet=T)
zipped_shape_names<-c("098_HELBIDE_SHP/ATRIBUTOAK-A098.cpg","098_HELBIDE_SHP/ATRIBUTOAK-A098.dbf","098_HELBIDE_SHP/ATRIBUTOAK-A098.shp","098_HELBIDE_SHP/ATRIBUTOAK-A098.shx")
unzip("my_file.zip", files=zipped_shape_names)
my_shape<-raster::shapefile("098_HELBIDE_SHP/ATRIBUTOAK-A098.shp")
但是我得到的是以下錯誤:
Error in rgdal::readOGR(dirname(x), fn, stringsAsFactors = stringsAsFactors, :
no features found
In addition: Warning messages:
1: In .local(x, ...) : .prj file is missing
2: In ogrFIDs(dsn = dsn, layer = layer) : no features found
您可以通過此鏈接並按“ Descargar planos”訪問原始網頁
我在其他領域沒有這個問題,只是在這個領域和另一個領域,但是我不知道這個特定領域正在發生什么。
任何幫助將不勝感激。
錯誤消息很清楚。 no features found
意味着您的shapefile為空。 您可以通過多種方式進行檢查。
一種是在Q-Gis或任何其他GIS軟件工具中添加shapefile。 對於Q-GIS,您的shapefile將在“層”窗格中彈出,但是您將看不到任何功能。
也可以在R中檢查.dbf
文件:
library(foreign)
read.dbf("098_HELBIDE_SHP/ATRIBUTOAK-A098.dbf")
.dbf
應該包含的行數與功能相同。 就您而言, None
。
更簡單的代碼是
library(raster)
url<-"http://www6.gipuzkoa.eus/CATASTRO/Planos/ZIP-A098.zip"
download.file(url, dest="my_file.zip")
unzip("my_file.zip")
s <- raster::shapefile("098_HELBIDE_SHP/ATRIBUTOAK-A098.shp")
顯然,該文件為空。 但是,它適用於此文件:
s <-raster::shapefile("098_LANDALUR_SHP/LANDALUR-PARTZELAK-A098.shp")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.