Hi, I've been trying to put shapefile in r studio
that's what I do
# Download the shapefile. (note that I store it in a folder called DATA. You have to change that if needed.)
download.file("http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip" , destfile="C:/Users/Administrator/Desktop/world_shape_file.zip(1)")
# You now have it in your current working directory, have a look!
# Unzip this file. You can do it with R (as below), or clicking on the object you downloaded.
system("C:/Users/Administrator/Desktop/world_shape_file.zip(1)")
# -- > You now have 4 files. One of these files is a .shp file! (TM_WORLD_BORDERS_SIMPL-0.3.shp)
# Read this shape file with the rgdal library.
library(rgdal)
my_spdf <- readOGR(
dsn= paste0(getwd(),"C:/Users/Administrator/Downloads/gadm36_shp.zip/gadm36.shp") ,
layer="gadm36",
verbose=FALSE)
library(rgdal)
s1<-readOGR("C:/Users/Administrator/Downloads/gadm36_shp.zip",'gadm36')
file.exists('C:/Users/Administrator/Desktop/TM_WORLD_BORDERS_SIMPL-0.3.ship')
# -- > Now you have a Spdf object (spatial polygon data frame). You can start doing maps!
Download successfully
Unzip successfully
But when I use readOGR, it only returns: Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
Cannot open data source
When I use file.exist()
it return false.
But I do have a shapefile downloaded on the Desktop. Can anyone fix it?