[postgis] PostgreSql point to Postgis point conversion
M Vermeij
mj_vermeij at yahoo.com
Mon Nov 26 05:41:45 PST 2001
I am trying to use the :
update a set g = geometryfromtext(('POINT(' ||
> x || ' '
> ||y||')')::geometry,123);
you mentioned. However instead of you're x and y
columns I would like to use the x and y coordinates
which are already stored in a postgres point field,
but can't seem to retrieve them seperately.
Question:
If the postgres point field is called 'location' what
whould the UPDATE command then be? ('location2' is the
PostGis point field.)
UPDATE table1 set location2 =geometryfromtext((
??????? )::geometry,-1);
--- Dave Blasby <dblasby at refractions.net> wrote:
> 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
>
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
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