[postgis-users] How to make this invalid polygon valid one
pcreso at pcreso.com
pcreso at pcreso.com
Sat Mar 10 13:26:10 PST 2012
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.
insert into test_polygon (id,geometry) values (1,ST_buffer(ST_GeomFromText(
--- 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
I am trying to create a buffer around my polygon, which unfortunately is not
a valid one.
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.
can someone tell me, what can I do, to remedy this behavior and to make this
this are the sql statements to reproduce my problem:
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 ;) )
-----Inline Attachment Follows-----
postgis-users mailing list
postgis-users at postgis.refractions.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users