[postgis-users] bug in st_difference() ?

Birgit Laggner birgit.laggner at vti.bund.de
Wed Mar 9 06:05:43 PST 2011


  Dear list,

when I am using ST_Difference(), I often have the problem, that the 
resulting geometries contain vertexes lying outside of the supposed 
geometry extent. My impression is that the function tries to preserve 
vertexes of the input geometries and does not check properly, whether 
the point lies inside the extent of the new geometry or not.

Here an example:

select st_astext(st_difference(a_geom, b_geom)) from 
st_geomfromtext('POLYGON((3580359 5328360,3588529 5330935,3597943 
5323120,3606024 5322587,3612951 5315217,3608155 5306691,3603804 
5305093,3596166 5306159,3591105 5310244,3584799 5310688,3576540 
5317437,3580359 5328360))',31467) as a_geom, 
st_geomfromtext('POLYGON((3597691.18360053 5323329.04452537,3597943 
5323120,3606024 5322587,3611561.81746298 5316695.02444028,3611480 
5316582,3605931 5322425,3597573 5323069,3597691.18360053 
5323329.04452537))',31467) as b_geom;

results in:
"POLYGON((3580359 5328360,3588529 5330935,3597943 
5323120,3597691.18360053 5323329.04452537,3597573 5323069,3605931 
5322425,3611480 5316582,3611561.81746298 5316695.02444028,3606024 
5322587,3612951 5315217,3608155 5306691,3603804 5305093,3596166 
5306159,3591105 5310244,3584799 5310688,3576540 5317437,3580359 5328360))"

Vertexes 4 (3597691.18360053 5323329.04452537) and 8 (3611561.81746298 
5316695.02444028) are out of the supposed geometry extent.

I am using PostGIS 1.5.2 with GEOS 3.2.2 on a 8.4.5 PostgreSQL-DB on 
64-bit SUSE Linux.

Maybe, there is a simple explanation, why this behavior might be wanted 
- if not, I would like to complain this as a bug (or at least suggest an 
improvement of the function in future versions)...

Regards,

Birgit.



More information about the postgis-users mailing list