[postgis-users] combine 2 columns into geometry column

Michael Fuhr mike at fuhr.org
Mon Aug 7 23:02:57 PDT 2006


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



More information about the postgis-users mailing list