I am trying to load a Shapefile using readShapeSpatial()
but I get the error
"Error in readShapeSpatial(shp) : File type cannot be read" .
Any ideas on what is going wrong here? Here is my code with the shapefile I'm using, which comes from the 2010 Brazilian Population Census.
# 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"))
The strange part is that I can load the file using readOGR
from package rgdal
shp <- readOGR(dsn="./SetorCensitario_2010_Rio/rj", layer="33MUE250GC_SIR")