[R-sig-Geo] Connection between R and PostGIS
Johannes Signer
j.m.signer at gmail.com
Wed Mar 28 15:01:07 CEST 2012
Dear All,
I have been trying to connect R and PostGIS. My approach so far is:
## load libraries
library(RODBC)
library(rgeos)
## Connect to db
con <- odbcConnect("gisdb")
## query
sql <- "SELECT ST_AsText(the_geom) from gis_data.gadm2 where name_2='Berlin'"
## execute query
d <- readWKT(sqlQuery(con, sql, stringsAsFactors=F)[1,1])
This works well for small polygons.
My questions are:
1.) Is there a more straightforward approach to access data stored
PostGIS from R?
2.) While my approach described above worked ok for small polygons, it
failed for larger ones. My guess is that the strings to be stored are
long. Does anyone has a workaround for that?
Thanks in advance for any comments
Johannes
More information about the R-sig-Geo
mailing list