[R-sig-Geo] Plot xyzm PostGIS Lines in rgl?

paallen at attglobal.net paallen at attglobal.net
Wed Feb 11 19:08:28 CET 2009


Hi all,

I have been plotting the midpoints of some
chemical analysis from drill holes in rgl and very
happy with the 3D symbolization capabilites.  Now
I want to try and plot some 3D lines of the drill
holes so I can symbolize some long intervals (not
usefull to plot as 3d  points).  

My data is in a PostGIS PostgreSQL database as
xyzm polylines.  What is the best way to get this
kind of data into R?  Should I export the data to
a shape file (pgsql2shp) then import with
readShapeSpatial?  I tried readOGR but apparentl
on windows it doesn't have the PG driver.  Or
should I bring the postgresql table in as text
like this:

Library(RODBC)
c <- odbcConnect("drill_hole_database")
d <- sqlQuery(c, "Select hole_id,
AsEWKT(hole_3dline_geom) as 3dline_txt FROM
drill_holes;")
d
hole_id		3dline_txt
ddh-1		SRID=32618:LINESTRING(4000 4000 325 0, 4000
4000 300 25, 4000 4000 250 75)
ddh-2		SRID=32618:LINESTRING(5000 5000 410 0, 5000
5000 350 60)

Of course my real data sets have more attributes,
vertices and the drill holes are curved!

With either the text or Spatial option I am having
problems re-formating the line vertices into the
lines3d format required by the rgl package.

If I can just get a good grip on managing spatial
data in R and symbolizing 3d data in rgl it will
save me a fortune.  3D mine/geology software is
expensive and typically has very limited
statistics beyond geostatistics.

thanks,

Phillip J. Allen
Chief Geochemist



More information about the R-sig-Geo mailing list