[R-sig-Geo] install rgdal to query postgis database

Duncan McPherson duncan at mcpherson.org.uk
Sun Aug 4 23:24:54 CEST 2013


An update that may shed some light on my issue:

Mysteriously it started working, I was able to import some spatial tables form PostGIS to R, and plot them, and I was about to thank the list and close the discussion, when it broke again. This was just after I updated some packages, so, through luck I still had the old version of rgdal and tried both.

The old one works, the new one doesn't. But the difference is also in the version of GDAL that is loaded. And, what is more confusing, is that once I have loaded the old version of rgdal, which has found the new version of GDAL, loading the new version of rgdal again also finds this new version of GDAL and works (see the session details below). However, my original problem was with the old version of rgdal and new version of GDAL, that now works.

Now I'm thoroughly confused. But here is a question:

Is there a way of controlling where rgdal looks for GDAL? And for other users, is it worth flagging this as an issue with rgdal, or is it some quirk of my system?

Thanks again,

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

loaded via a namespace (and not attached):
[1] tools_3.0.1
> dsn="PG:dbname=health_england user=postgres"
> ogrListLayers(dsn)
Error: could not find function "ogrListLayers" #obviously
> library("rgdal", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library")    #The NEW version, that fails
Loading required package: sp
rgdal: version: 0.8-10, (SVN revision 478)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.9.2, released 2012/10/08
Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/rgdal/gdal
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/rgdal/proj
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] rgdal_0.8-10 sp_1.0-11   

loaded via a namespace (and not attached):
[1] grid_3.0.1      lattice_0.20-15 tools_3.0.1    
> ogrListLayers(dsn)
Error in ogrListLayers(dsn) : Cannot open data source
> detach("package:rgdal", unload=TRUE)
Warning messages:
1: In FUN(X[[2L]], ...) :
  Created a package name, ‘2013-08-04 21:51:37’, when none found
2: In FUN(X[[2L]], ...) :
  Created a package name, ‘2013-08-04 21:51:37’, when none found
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] sp_1.0-11

loaded via a namespace (and not attached):
[1] grid_3.0.1      lattice_0.20-15 tools_3.0.1    
> library("rgdal", lib.loc="/Users/duncan/Library/R/3.0/library")    #The OLD version, that works
rgdal: version: 0.8-8, (SVN revision 463)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.10.0, released 2013/04/24
Path to GDAL shared files: 
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: (autodetected)
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] rgdal_0.8-8 sp_1.0-11  

loaded via a namespace (and not attached):
[1] grid_3.0.1      lattice_0.20-15 tools_3.0.1    
> ogrListLayers(dsn)
 [1] … [list of layers]
> detach("package:rgdal", unload=TRUE)
Warning messages:
1: In FUN(X[[2L]], ...) :
  Created a package name, ‘2013-08-04 22:06:10’, when none found
2: In FUN(X[[2L]], ...) :
  Created a package name, ‘2013-08-04 22:06:10’, when none found
> library("rgdal", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library")	#The NEW version again, now it works
rgdal: version: 0.8-10, (SVN revision 478)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.10.0, released 2013/04/24
Path to GDAL shared files: 
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/rgdal/proj
> ogrListLayers(dsn)
 [1] …[list of layers] 



More information about the R-sig-Geo mailing list