I have installed postgres, postgis, gdal 'complete' all from kyngchaos. Then I loaded a map of England, and have been able to do manipulations of that with SQL statements. I can also create maps with QGis by loading Postgis layers within QGis. And, I can use the utilities in terminal, e.g.:
iMac:~ duncan$ ogrinfo -ro "PG:dbname=health_england user=postgres"
INFO: Open of `PG:dbname=health_england user=postgres'
using driver `PostgreSQL' successful.
?[list of layers]
Further, I have installed R64 and RStudio, the packages DBI and RPostgreSQL and am able to query the non-map parts of the database:
Now the problem:
I need to be able to produce many maps from this database within R, so that I can, for example, use the non-map analyses above to colour the map areas. I want to do this programmatically because of the number of maps (also the reason for not wanting to save out a shapefile of every map), rather than produce each one in QGis. From reading around, including this: http://gis.stackexchange.com/questions/64950/which-is-the-best-way-of-working-with-postgis-data-in-r, that rgdal would be able to handle the database connection and correctly handle the geometry columns, which RPostgreSQL cannot. But I keep getting this:
Error in ogrListLayers(dsn) : Cannot open data source
Information that may be useful if you were to be able to help me might be:
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] RPostgreSQL_0.4 DBI_0.2-7 rgdal_0.8-8 sp_1.0-9
loaded via a namespace (and not attached):
[1] grid_3.0.1 lattice_0.20-15 tools_3.0.1