[postgis-users] Polygon from a set of points

Kevin Neufeld kneufeld at refractions.net
Tue Jun 12 12:59:28 PDT 2007


Have you tried using convexhull(geometry)? Given a collection of points, 
it'll return a polygon where every point is guaranteed to be inside the 
polygon.
ie.
SELECT convexhull(collect(makepoint(x,y))) FROM mytable;

-- Kevin

Leonardo Mateo wrote:
> Hi guys, I need to build a polygon from a set of dynamic points. By
> dynamic I mean that I will be getting sets of x,y coordinates which
> will vary from one request to another. (it is a web application).
> I was reading postgis docs, but I can't figure out how to do it. What
> I tried was:
> For each (x,y), make a point and then make a line as I know the order, 
> i.e.:
>
> MakeLine(MakePoint(-67.84208673890122, -31.89216012405324),
> MakePoint(-67.84097873325344, -31.8878559482676))
>
> Then, I tried to use MakePolygon(linestring, [linestring[]]) function,
> but I can't figure out how to make the linestring[] with Accum as is
> suggested by Postgis docs.
>
> Any Clues?
>
> Thanx a lot in advance.
>



More information about the postgis-users mailing list