[postgis-users] Semantics of difference() function

Andy Anderson aanderson at amherst.edu
Wed Jun 4 19:03:08 PDT 2008

On Jun 4, 2008, at 11:49 AM, Martin Davis wrote:
> To answer a question you posed on your blog, the reason that when  
> you subtract a line from a polygon you get basically the same  
> polygon, rather than say the polygon split into two halves, is that  
> if the latter was provided as a MultiPolygon it would be invalid,  
> because the halves would share line segments down the middle.  Also,  
> if the line did not fully overlap the polygon there's no choice -  
> you have to return the original poly.  The behaviour is thus  
> consistent between the two cases.

> Unfortunately the SFS (and no other standard I'm aware of) doesn't  
> define the precise semantics of the overlay operations.  So I made  
> 'em up!  Hopefully they are consistent and reasonable.  There's no  
> doubt alternative definitions which might be useful in some cases -  
> but you have to choose one definition for any given function.  (For  
> the situation above, many people would like a "cut polygon by line"  
> operation - hopefully that will get provided as a new function  
> sometime soon).

I've seen "split" as a term that is commonly used for such operations,  

geometry = ST_Split(geometry1, geometry2)

This should be defined for geometry1 of dimensionality D ≥ 1 and  
geometry2 of dimensionality D or D-1, i.e. (polygon, polygon),  
(polygon, line), (line, line), and (line, point). The result should be  
GeometryType(geometry) == 'GeometryCollection' where for any n  
GeometryType(ST_GeometryN(geometry, n)) == GeometryType(geometry1).

-- Andy

More information about the postgis-users mailing list