[postgis] PostgreSql point to Postgis point conversion
Dave Blasby
dblasby at refractions.net
Mon Nov 19 09:39:39 PST 2001
Here's the easiest way to do it - just use postgresql's builtin TEXT
type to create the WKT:
t1=# create table a (x float, y float, g geometry);
....
t1=# select * from a;
x | y | g
----+----+---
1 | 2 |
11 | 22 |
(2 rows)
To make these into points, we make some WKT (|| is the concat operator):
t1=# select 'POINT(' || x || ' ' ||y||')' from a;
?column?
--------------
POINT(1 2)
POINT(11 22)
(2 rows)
So,
t1=# update a set g = geometryfromtext(('POINT(' || x || ' '
||y||')')::geometry,123);
t1=# select * from a;
x | y | g
----+----+-----------------------
1 | 2 | SRID=123;POINT(1 2)
11 | 22 | SRID=123;POINT(11 22)
(2 rows)
dave
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Universal Inkjet Refill Kit $29.95
Refill any ink cartridge for less!
Includes black and color ink.
http://us.click.yahoo.com/r9F0cB/MkNDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the postgis-users
mailing list