[R-sig-Geo] Connection between R and PostGIS
Alex Mandel
tech_dev at wildintellect.com
Wed Mar 28 18:26:32 CEST 2012
I personally prefer RPostgreSQL over RODBC.
This has a decent discussion of the current limitations and alternate ideas
http://code.google.com/p/rpostgresql/issues/detail?id=22
The other way I can think to do it, is the ManageR plugin in QGIS.
Thanks,
Alex
On 03/28/2012 06:14 AM, Edzer Pebesma wrote:
> see
>
> http://wiki.intamap.org/index.php/PostGIS
>
> (which, to my surprise, has been accessed nearly 30000 times).
>
> On 03/28/2012 03:01 PM, Johannes Signer wrote:
>> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list