[R-sig-Geo] Error in reading shape file with readOGR()

Amos Thairu thairua at gmail.com
Tue Jan 27 14:50:24 CET 2015


I am trying to import a shapefile using readOGR below:
> dataProjected <- readOGR(dsn="~/datasets/mapping", layer="locations")

But I am facing the following error:
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv =
use_iconv,  :
  Cannot open file

I have successfully loaded the same shapefile using readOGR in my windows
platform but cannot read that same file
using the same command in a linux platform. I guess the problem seems to be
related to having uploaded the
.shp and its associated files from a Windows machine onto the linux
platform.

The directory with the shape file is complete with the associated files as
shown below:
> list.files("~/datasets/mapping")
[1] "locations-c.dta"   "locations-d.dta"   "locations.dbf"
"locations.prj"     "locations.sbn"
[6] "locations.sbx"     "locations.shp"     "locations.shp.xml"
"locations.shx"

I get the following package startup message:
> library(rgdal)
Loading required package: sp
rgdal: version: 0.9-1, (SVN revision 518)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.3, released 2010/11/10
Path to GDAL shared files: /usr/share/gdal
GDAL does not use iconv for recoding strings.
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
Path to PROJ.4 shared files: (autodetected)

My session info is as follows:
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.9-1 sp_1.0-17

loaded via a namespace (and not attached):
[1] grid_3.1.2      lattice_0.20-29 tools_3.1.2

Does anyone know why this is happening? Any assistance would be greatly
appreciated.

-- 
Regards,
Amos Mbugua.

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list