[postgis-users] Generating Point geometry

strk at refractions.net strk at refractions.net
Tue Aug 9 12:47:12 PDT 2005


On Tue, Aug 09, 2005 at 12:00:55PM -0700, Robyn Rennie wrote:
> Hi all, 
> I am new to PostGIS and I have installed it onto an existing PostgreSQL database. I have a table with an x and a y column and want to make a point geometry from these columns. 
> I have done the following
> SELECT AddGeometryColumn('table_xy_45700522','xypoint',-1,'POINT',1);
> ALTER TABLE table_xy_45700522 DROP CONSTRAINT enforce_dims_xypoint;  - needed because it seemed to fail otherwise?

Last argument is geometry dimension. 1 should not be allowed
(what version are you using?). If you use 2 there you won't
need to drop the CONSTRAINT.

> and now have a table which looks like samplename (varchar), x(float8), y(float8), xypoint(geometry). There are 800+ records in the table all with values in the samplename, x and y columns. How can I use MakePoint or some other function to get the geometry for each of these points?  (this is a test table - the real table has considerably more points)
> Looking through the archives I only see references to loading the data from an external file.
> Thanks for any assistance.

This is an SQL question, you must UPDATE you TABLE setting the
value for the xypoint:

UPDATE TABLE <tablename> SET xypoint = MakePoint(x, y);

--strk;



More information about the postgis-users mailing list