[postgis-users] Build polygons from points

Brent Wood pcreso at pcreso.com
Tue Jan 30 12:22:34 PST 2007


--- galen <galen at shackprices.com> wrote:

> 
> Say I have 500 points that represent an area and I'm hoping to build a 
> polygon out of those points.  Is there a good function to do this in 
> postgis or a good program that anyone has written that can accommodate 
> this?  Obviously there is no "perfect" method of building polygons from 
> points, but a function that accepted some inputs (like concavity 0-10 or 
> something, similar to the way Simplify works?) would seemingly help me 
> refine the "perfect' method for my purposes.


Do you require the points to form the perimeter (ie, make them the vertices of
the polygon) or do they extend throughout the area?

Is there any value specifying sequentiality for the points, or is there no
defined order?



One possible approach:

Can you assign the points a common Z value?

That would let you generate a surface from the points. Contouring this surface
would generate a contour approximating the perimeter. Tools like R, GRASS & GMT
could do this. 

The precision would depend on point spacing & the surface resolution, but you
should be able to constrain the surface to ensure a pretty good fit. The GMT
surface command has a tension parameter which is much like your concavity
suggestion.

The forthcoming OGR driver for GMT would simplify this sort of thing as your
PostGIS points could be piped directly into GMT to generate the surface. The
GMT generated contour could then be ogr2ogr'd back into a PostGIS table.

Cheers,

  Brent



More information about the postgis-users mailing list