<div>I'd like to point out that this sounds similar to the ELIMINATE command  in ArcGIS.</div>
<div> </div>
<div>And be aware that the area parameter is missing so called '<b>dumb-bell</b>' polygons, which means sliver polygons which are very small but also very long. In this case, an additional parameter would be of help: The circumference.</div>

<div> </div>
<div>Any ideas? </div>
<div> </div>
<div>-S.</div>
<div> </div>
<div>P.S. CLEAN is another cleansing command. See my next post. <br><br></div>
<div class="gmail_quote">2009/2/4 Yves Moisan <span dir="ltr"><<a href="mailto:yves.moisan@boreal-is.com">yves.moisan@boreal-is.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Kevin,<br><br>Thanx a lot.  I ended up doing the few remaining by hand.  I could start<br>from the linestring and figure out where the bad vertex was.  Not all<br>
the polygons I had closed and some even missed a side or two, so no hope<br>for any algorithm there.  I'll study what you're proposing and see how<br>many remaining non valid geometries remain.<br><br>Thanx again for your helpful comments.<br>
<br>Yves<br><br>Le mardi 03 février 2009 à 14:11 -0800, Kevin Neufeld a écrit :<br>
<div>
<div></div>
<div class="Wj3C7c">> Hi Yves,<br>><br>> No, you can't set a tolerance on building an area.  Depending on your requirements, you can snap all the vertices in the<br>> geometry to some grid so that such polygons do close.<br>
><br>> Using OpenJUMP, I can see in your example that your linear ring falls short of about 0.15 units from closing.  So, this<br>> should work:<br>><br>> UPDATE mytable<br>> SET the_geom = ST_BuildArea(<br>
>         ST_Union(<br>>            ST_Boundary(ST_SnapToGrid(the_geom, 0.2)),<br>>            ST_Startpoint(ST_Boundary(ST_SnapToGrid(the_geom, 0.2)))<br>>         )<br>>      )<br>> WHERE id = 122;<br>
><br>> If snapping the entire geometry to a grid is not preferable to you, then you're left with some mucky business, but I<br>> think you can do it.<br>> 1. extract and node the exterior ring (your geometry runs back on itself so you can't tell where the start and endpoints<br>
> of the exterior ring lie)<br>> 2. merge the ring to a single linestring (making the start and end points obvious)<br>> 3. update the startpoint to be equal to the endpoint<br>> 4. repolygonize.<br>><br>><br>
> CREATE TABLE tmp AS<br>> SELECT id,<br>>    -- Create a single linestring<br>>    ST_LineMerge(<br>>      -- Remove overlapping segments<br>>      ST_Union(<br>>        ST_Boundary(the_geom),<br>>        ST_StartPoint(ST_Boundary(the_geom))<br>
>      )<br>>    ) AS the_geom<br>> FROM mytable<br>> WHERE id = 122;<br>> -- At this point, you should only have LINESTRINGs in tmp, not MULTILINESTRINGs.  You should verify this to see if you<br>> have other problems than just the endpoints not closing.<br>
><br>> UPDATE mytable a<br>> SET the_geom =<br>>    ST_BuildArea(<br>>      ST_SetPoint(b.the_geom, 0, ST_EndPoint(b.the_geom)))<br>> FROM tmp b<br>> WHERE <a href="http://a.id/" target="_blank">a.id</a> = <a href="http://b.id/" target="_blank">b.id</a>;<br>
><br>> Yields a single polygon for id=122:<br>> POLYGON ((<br>>          375838.8459248 8718402.9401143,<br>>          375844.0704528 8718410.3968027,<br>>          375904.0280814 8718366.8994515,<br>>          375898.8035535 8718359.4427696,<br>
>          375838.8459248 8718402.9401143<br>>      ))<br>><br>><br>> It would complicate things if you have holes in your non-closing polygons, but for starters this should do for you.<br>><br>> Hope that helps,<br>
> Kevin<br>><br>> Yves Moisan wrote:<br>> > [cut] Can I either set some tolerance on the buildarea so it<br>> > snaps to the closest point in the case the multilinestring does not<br>> > close or enforce a constraint on the union so it produces a closed<br>
> > linestring ?<br>> ><br>> _______________________________________________<br>> postgis-users mailing list<br>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br><br>_______________________________________________<br>postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br>