を使用してシェープファイルを読み込もうとしてreadShapeSpatial()
いますが、エラーが発生します
「readShapeSpatial(shp) のエラー: ファイル タイプを読み取れません」 .
ここで何がうまくいかないのかについてのアイデアはありますか? これは、2010 年のブラジル国勢調査から取得したシェープファイルを使用したコードです。
# Load Libraries
library(maptools)
library(rgdal)
# Set Working Directory
setwd("C:/Users/rafa/Desktop/test_shape")
# Download official shape files
download.file("ftp://geoftp.ibge.gov.br/malhas_digitais/censo_2010/setores_censitarios/rj.zip", "SetorCensitario_2010_Rio.zip", quiet = FALSE)
# Unzip files
unzip("SetorCensitario_2010_Rio.zip", exdir="SetorCensitario_2010_Rio")
# Load shapefile using `readShapeSpatial`
shp<- "C:/Users/rafa/Desktop/test_shape/SetorCensitario_2010_Rio/rj/33MUE250GC_SIR.shp"
shp <- readShapeSpatial(rioshape, proj4string = CRS("+proj=longlat +datum=WGS84"))
readOGR
奇妙な部分は、 from packageを使用してファイルをロードできることですrgdal
shp <- readOGR(dsn="./SetorCensitario_2010_Rio/rj", layer="33MUE250GC_SIR")