[postgis-users] Strange behaviour with st_difference

Mike Leahy mgleahy at alumni.uwaterloo.ca
Tue Jan 13 01:41:04 PST 2009


Mark Cave-Ayland wrote:
> 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
> 
> 
> 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 :)
> 
> 
> ATB,
> 
> Mark.
> 


Here they are attached - both as text and as binary within an sql 
statement that replicates the results of the example describe above.

postgis_full_version (from the yum repo on Fedora 10, x86_64):

                                 postgis_full_version
-------------------------------------------------------------------------------------
  POSTGIS="1.3.5" GEOS="3.0.3-CAPI-1.4.2" PROJ="Rel. 4.6.1, 21 August 
2008" USE_STATS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g1g2.sql.gz
Type: application/x-gzip
Size: 2004 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090113/d75f9af9/attachment.bin>


More information about the postgis-users mailing list