[postgis-users] Can I create a Polygon using Points rather than x y coordinates

Robert Coup robert.coup at onetrackmind.co.nz
Mon Jan 19 11:11:29 PST 2009


Hi Donna,

On Tue, Jan 20, 2009 at 3:37 AM, DonnaR <donna at therudds.co.uk> wrote:

>
> Can I construct a Polygon from a set of (already constructed) Points? The
> std
> way seems to be by 'creating' the Points implicitly ie POLYGON(x y, x
> y,...), but I have already constructed the geometry Points (so I can do
> some
> other processsing on them first) and so just need to pass them in as Points
> to the Polygon constructor.


Have a look at ST_MakePolygon, ST_MakeLine, and ST_LineFromMultiPoint...

http://postgis.refractions.net/documentation/manual-1.3/ch06.html#id2748776

Maybe something like:
SELECT ST_MakePolygon(ST_MakeLine(p)) FROM (SELECT p FROM mypoints ORDER BY
index) AS mypointsordered;

Note that the linestring must be closed before you can successfully call
MakePolygon()

HTH,

Rob :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090120/75d8b7d4/attachment.html>


More information about the postgis-users mailing list