[postgis-users] problems cleaning geometry - other options?

William Kyngesburye woklist at kyngchaos.com
Thu Dec 4 10:46:52 PST 2008


On Dec 4, 2008, at 10:53 AM, Kevin Neufeld wrote:

> Correct.  I assumed in your case that the rings do not need to be  
> noded against eachother (that's what st_union is for), they just  
> need to be sorted to determine the outer and inner rings (that's a  
> task for BuildArea).
> Glad it works.
> -- Kevin
>
> William Kyngesburye wrote:
>> That works.  It looks essentially the same as what's in the  
>> cleangeometry function from the wiki, but much simpler.  There's  
>> st_union and st_multi in there betwen the buildarea and boundary  
>> functions, probably to handle other invalid stuff.
>> On Dec 4, 2008, at 1:02 AM, Kevin Neufeld wrote:
>>> Have you tried updating the geometry with a new polygonized  
>>> polygon constructed from the linework?
>>>
>>> UPDATE swbd
>>> SET wkb_geometry = ST_BuildArea(ST_Boundary(wkb_geometry))
>>> WHERE cell = 145018 AND wb = 353;
>>>
>>> Cheers,
>>> -- Kevin
>>


I wonder if there is a way for a postgres function to see what the  
actual kind of validity error is (it just comes up as a NOTICE: in the  
sql output)?  I ran thru the whole database to see how many invalid  
polys there are (10700 of 625000) and what they are (and how long it  
will take just to test validity... 5m, not bad), and I see more than  
just this one case I first ran into (hole outside shell):

NOTICE:  Hole lies outside shell at or near point x y  [not many of  
these]
NOTICE:  Nested shells at or near point x y  [lots of these]
NOTICE:  Holes are nested at or near point x y  [lots of these]
NOTICE:  Self-intersection at or near point x y
NOTICE:  Ring Self-intersection at or near point x y
NOTICE:  Interior is disconnected at or near point x y  [a few of these]

It would be nice if the cleangeometry function could use the right  
combination of geometry operations depending on the type of geometry  
error.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"Those people who most want to rule people are, ipso-facto, those  
least suited to do it."

- A rule of the universe, from the HitchHiker's Guide to the Galaxy





More information about the postgis-users mailing list