[postgis-users] ST_SnapToGrid makes a geometry lose its validity

Sandro Santilli strk at keybit.net
Wed Feb 20 08:38:38 PST 2013


On Wed, Feb 20, 2013 at 05:09:18PM +0100, Paolo Crosato wrote:
> Hi,
> 
> I have a test case for a geometry that lose its validity when
> snapped by ST_SnapToGrid.
> The geometry is pretty big, I attached it to the message.
> You can test the behaviour with:
> 
> select ST_isValid(<geom>);
> --t
> select ST_isValid(ST_SnapToGrid(<geom>,1e-6));
> --f
> 
> I know the function could make the geometry lose its simplicity,
> however the documentation does not
> say anything about validity.

A polygon whose boundary is non-simple is an invalid polygon.
All expected. It's always a collapse (an area which becomes
a line or a point). Use ST_MakeValid and ST_CollectionExtract
to strip out the collapsed portions.

--strk;


More information about the postgis-users mailing list