[R-sig-Geo] reading spatial coordinates from a database

Edzer J. Pebesma e.pebesma at geo.uu.nl
Fri Aug 31 11:09:48 CEST 2007


Sebastien, a possible way to get your data in R is through the readOGR 
function in package rgdal that can read from a PostGIS data base. Not 
being an expert, from your example below it seems that the polygon data 
are in some PostGIS form, WKT or something like that. You'll find some 
examples on

http://wiki.intamap.org/index.php/PostGIS

Hope this helps,
--
Edzer

Sebastien wrote:
> Dear R users,
>
> I work with the RODBC package. I would like to read the coordinates xy 
> of a polyline in a table called 'populations'. The connexion with the 
> database (postgresql) seems good but when I try to select the 
> coordinates of a population, the string of characters is truncated at 
> 255 character which is too short to obtain all the point of the 
> corresponding polyline. An example with the populations 5396 :
>
> library(RODBC)
> channel <- odbcConnect("colza_ansi")
> cde <- paste('select xy from populations where id_pop=5396;')
> xy <- sqlQuery(channel, cde)
>
> xy
> 1 
> [(515041.60200000001,2306276.1310000001),(515041.59899999999,2306276.1359999999), 
>
> (515041.59600000002,2306276.1320000002),(515041.59100000001,2306276.1409999998), 
>
> (515041.59100000001,2306276.1340000001),(515041.61700000003,2306276.1170000001), 
>
> (515041.618000
>
>
> There is probably a parameter to change but I don't find which one. 
> Could someone help me?
> Thanks
>
> Sébastien Ollier
> University of Paris
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list