[postgis-users] Strange behaviour with st_difference
Martin Davis
mbdavis at refractions.net
Tue Jan 13 11:42:36 PST 2009
This is expected behaviour. The difference is due to the effects of
finite precision and rounding. Basically your only choice for avoiding
this kind of behaviour is to control your precision model, by using
SnapToGrid or some other equivalent approach.
Or, you can change the process that consume this result to be more
tolerant of very small discrepancies.
Mike Leahy wrote:
> Hello list,
>
> I'm having a problem with st_difference, where two overlapping
> geometries will return an empty geometrycollection, as if the do not
> overlap. However, if I use st_difference on the same geometries, but
> converted to EWKT, then back, then using st_difference yields the
> expected output. Basically, this is what I'm getting (minus the
> output coords):
>
> # select st_astext(st_difference(g1,g2)),
> st_astext(st_difference(st_asewkt(g1),st_asewkt(g2))) from temp;
> st_astext | st_astext
> --------------------------+-------------------------------
> GEOMETRYCOLLECTION EMPTY | POLYGON(( .... ))
> (1 row)
>
>
> The resulting (correct) polygon is very small (a total area of
> 0.00048828125, using UTM coordinates), so maybe there's a problem with
> that? The result of st_overlaps(g1,g2) is true for the same data that
> cause this problem.
>
> I could email someone the geometries if that would help.
>
> Regards,
> Mike
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
More information about the postgis-users
mailing list