<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 3, 2013 at 11:50 AM, James David Smith <span dir="ltr"><<a href="mailto:james.david.smith@gmail.com" target="_blank">james.david.smith@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On 3 December 2013 15:55, Lee Hachadoorian <span dir="ltr"><<a href="mailto:Lee.Hachadoorian+L@gmail.com" target="_blank">Lee.Hachadoorian+L@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>On Tue, Dec 3, 2013 at 5:23 AM, James David Smith <span dir="ltr"><<a href="mailto:james.david.smith@gmail.com" target="_blank">james.david.smith@gmail.com</a>></span> wrote:<br>
</div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
Hi all,<div><br></div>
<div>Apologies for cross-posting this to the RPostrgeSQL and PostGIS mailing lists, but I'm not sure where the problem lies.</div><div><br></div><div>I am using the RPostgreSQL package of R to connect to my installation of PostgreSQL/PostGIS. I want to retrieve some coordinates from my database and run the below command. Is this just that R doesn't know what to do with Geometry's, or is it something I should be more concerned about? I ask, as I'm having some wider issues with my workflow and this may be related.</div>
<div><br></div><div>Thanks</div><div><br></div><div>James</div><div><br></div><div><pre style="line-height:15px;font-size:14px;background-color:rgb(225,226,229);margin-bottom:0px;font-family:Consolas,'Lucida Console',monospace;margin-top:0px;border:medium none;outline:medium none;white-space:pre-wrap!important">
<span style="white-space:pre-wrap;color:blue">> </span><span style="color:blue">dbGetQuery(con, "SELECT st_transform(st_setsrid(st_makepoint(soose::numeric, soosn::numeric),27700),4326) FROM stage WHERE ssid = '707187161010202'")
</span> </pre><pre style="line-height:15px;font-size:14px;background-color:rgb(225,226,229);margin-bottom:0px;font-family:Consolas,'Lucida Console',monospace;margin-top:0px;border:medium none;outline:medium none;white-space:pre-wrap!important">
st_transform
1 0101000020E6100000F71184EF3961B3BF830420AF33C64940
<span style="color:rgb(197,6,11)">Warning message:
</span><span style="color:rgb(197,6,11)">In postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver warning: (unrecognized PostgreSQL field type geometry (id:480912) in column 0)</span></pre><pre style="line-height:15px;font-size:14px;background-color:rgb(225,226,229);margin-bottom:0px;font-family:Consolas,'Lucida Console',monospace;margin-top:0px;border:medium none;outline:medium none;white-space:pre-wrap!important">
<span style="color:rgb(197,6,11)"><br></span></pre></div></div></blockquote><div class="gmail_quote"><br></div></div></div>James,<div><br></div><div>R knows how to handle geometries using the sp package, but can't read the data in using RPostgreSQL. You would need to use readOGR() in the rgdal package. But what data do you actually need in R, and what do you intend to do with it? If you're not going to be mapping it or doing spatial statistics on it, there may be a way to get the data you want using RPostgreSQL.</div>
<div><br></div><div>Best,</div><div>--Lee </div></div></div></div></blockquote><div><br></div></div></div><div>Hi Lee,</div><div><br></div><div>Thanks for the reply. I was really only after the x and y of the geom, so I'm now using st_x and st_y functions to get that. I've also figured out what was going on with my wider workflow (a typo!) , so now all is working fine. It was good to understand how R deals with geom types though for future reference.</div>
<div><br></div><div>Cheers</div><span class=""><font color="#888888"><div><br></div><div>James</div><div><br></div></font></span></div></div></div></blockquote><div><br></div><div>That's what I suspected, so I was going to suggest what you've already figured out. BTW, R + PostGIS is an excellent toolchain, so if you do decide to push in that direction, Advanced Spatial Data Analysis with R by Bivand, et al. will be indespendible.<br>
<br><a href="http://www.asdar-book.org/">http://www.asdar-book.org/</a><br><br></div><div>Best,<br></div><div>--Lee<br></div></div></div></div>