[R-sig-Geo] readOGR problem in Windows
Alex Mandel
tech_dev at wildintellect.com
Tue Dec 23 17:43:10 CET 2014
On 12/23/2014 07:43 AM, James Rooney wrote:
> Dear List,
>
> I have some code I have developed on a Mac that I'm trying to transfer onto a higher spec windows 8.1 machine and I am running into a problem with the readOGR function in rgdal.
>
> My code is below. This works fine under Mac, but under windows readOGR gives me the error:
> "Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
> Cannot open file "
>
> The rgdal version on the Mac is rgdal_0.8-16
> whilst on Win 8.1 is rgdal 0.9-1
>
> The preceding read.csv statement works just fine.
> Any ideas anyone ?
> Thanks,
> James
>
>
> Code:
>
> library(rgdal)
> library(rgeos)
> library(maptools)
> library(RColorBrewer)
> library(classInt)
> library(ggplot2)
> library(INLA)
>
>
> # Set working directory
> setwd("/Users/james/Project Work")
>
^^ Pretty sure this line would fail on windows, so your code won't be
running in the correct directory when it gets to the readOGR later.
Windows absolute paths start with a drive letter.
> source("R_Files/Ireland - General Functions/SA.data-prep.functions.R")
>
> # Load soils databse
> soils <- read.csv("Irish Data/NSDB_SA_kriged.csv", header=TRUE)
>
Though you say this one works? odd?
> # Load shape files and data file
> SA <- readOGR("./Irish Data/Processed Data/","SA.basic.analysis.shapes",TRUE)
>
No idea what Windows does with ./
Overall I think you need to verify the path that R is on, and that it
can actually see the files before it tries to load them.
Thanks,
Alex
More information about the R-sig-Geo
mailing list