[postgis-users] How to make this invalid polygon valid one

Puneet Kishor punk.kish at gmail.com
Sat Mar 10 13:37:23 PST 2012



ha! Neat trick, Brent.

On Mar 10, 2012, at 3:26 PM, pcreso at pcreso.com wrote:

> Hi Nicolas,
> 
> Change your SQL to insert a buffered version of your polygon with a buffer distance of zero. You should get a topologically correct polygon (in this particular case anyway), which is a tracing of the perimeter with any duplicate vertices resolved.
> 
> eg: 
> 
> insert into test_polygon (id,geometry) values (1,ST_buffer(ST_GeomFromText(
> 'POLYGON((...))'),0.0));
> 
> Cheers,
> 
>   Brent Wood
> 
> --- On Sun, 3/11/12, Nicolas Ribot <nicolas.ribot at gmail.com> wrote:
> 
> From: Nicolas Ribot <nicolas.ribot at gmail.com>
> Subject: Re: [postgis-users] How to make this invalid polygon valid one
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Date: Sunday, March 11, 2012, 9:45 AM
> 
> Hello
> 
> I am trying to create a buffer around my polygon, which unfortunately is not
> a valid one.
> (reason: "Self-intersection[......]").
> 
> This polygon is the output of my calculation that creates from a set of
> connected edges an area, consisting of all edges located on the border.
> 
> http://postgis.17.n6.nabble.com/file/n4564623/Screen_Shot_2012-03-09_at_10.02.41_PM.png
> Polygon image
> 
> can someone tell me, what can I do, to remedy this behavior and to make this
> geometry valid
> 
> this are the sql statements to reproduce my problem:
> http://postgis.17.n6.nabble.com/file/n4564623/testPolygon.sql
> testPolygon.sql
> 
> thanks
> 
> Markus
> 
> 
> 
> Hi Markus,
> 
> An attempt with Pgis 1.5.3:
> 
> I saw in a Paul's presentation the power of unioning linestrings together, in order to generated several line where they intersects (http://2010.foss4g.org/presentations_show.php?id=3369)
> 
> The goal is to use duplicate points from the initial polygon to allow us to make the difference between these points and the exterior ring of the polygon, to generates several linestrings that can be passed to st_buildArea:
> 
> The first part (with...) extracts duplicate points (cf img1)
> 
> with duplicates as (
>       select st_collect((st_dumppoints(geometry)).geom) as point
> 	 from test_polygon 
> 	 group by (st_dumppoints(geometry)).geom
> 	 having count((st_dumppoints(geometry)).geom)>1
>  ) 
>  select st_buildarea (
>       st_union(st_difference(st_exteriorRing(t.geometry), point))  
>  ) from duplicates, test_polygon t;
> 
> The result (img2) is a multipolygon that can be dumped to extract individual parts, or directly buffered.
> (the query is not at all optimized ;) )
> 
> Nicolas
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120310/9415a2f9/attachment.html>


More information about the postgis-users mailing list