[postgis-users] Creating a linestring from two points

David Blasby dblasby at refractions.net
Mon Nov 4 09:41:41 PST 2002


Per-Olof,

Unfortunately OGC didnt define any constructors for geometries.  I should
really add a few functions to do this - perhaps I'll get some time in the
next little while.

If you want to construct a line from 2 points, I suggest you build up a WKT
string:

Lets look at a simple example - a table with 3 geometry columns called
'point1','point2','line'.  The point1 and point2 column have points in them.

The function xmin(geometry) returns the xmin of the geometry's bounding
box.  For a point, the points X value is the same as the bounding box's X
value.  The '||' operator concatenates 2 strings.

UPDATE <table>  SET line =
    geometryFromText(
       'LINESTRING('|| xmin(point1)||' ' || ymin(point1) ||','||
xmin(point2) || ' '||  ymin(point2) || ')'
    );

dave





More information about the postgis-users mailing list