[postgis-users] combine 2 columns into geometry column

Donal Regan donal_regan10 at yahoo.co.uk
Mon Aug 7 23:15:31 PDT 2006


Perfect. Thank you.

Michael Fuhr <mike at fuhr.org> wrote: On Tue, Aug 08, 2006 at 06:49:55AM +0100, Donal Regan wrote:
> What is the quickest way to combine 2 columns x and y into a
> single geometry column of type point?

You might be looking for MakePoint().  Here's an example:

test=> SELECT * FROM foo;
 id | x  | y  | geom 
----+----+----+------
  1 | 12 | 34 | 
  2 | 56 | 78 | 
(2 rows)

test=> UPDATE foo SET geom = MakePoint(x, y);
UPDATE 2
test=> SELECT id, x, y, AsText(geom) FROM foo;
 id | x  | y  |    astext    
----+----+----+--------------
  1 | 12 | 34 | POINT(12 34)
  2 | 56 | 78 | POINT(56 78)
(2 rows)

-- 
Michael Fuhr
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


 		
---------------------------------
 Inbox full of spam? Get leading spam protection and 1GB storage with All New Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060808/bff04f90/attachment.html>


More information about the postgis-users mailing list