[postgis-users] Strange behaviour with st_difference

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Tue Jan 13 01:04:15 PST 2009

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
> --------------------------+-------------------------------
> (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

Hi Mike,

I think you'll have to post the geometries if you want someone to help 
you. If they are large then place them in a text file and send it to the 
list as a zipped/gzipped attachment.

Oh, and don't forget the output of "SELECT postgis_full_version()" while 
you're at it :)



Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
T: +44 870 608 0063

More information about the postgis-users mailing list