[postgis-users] Merge lines

Kevin Neufeld kneufeld at refractions.net
Wed Oct 7 11:18:54 PDT 2009


Sufficool, Stanley wrote:
  > How would the bounding box on a point be a problem with group by? I am
> aware of the classic example of a line 0,0-5,5 and 0,5-5,0 being treated
> as same when grouped. But does this really apply to points?

Unfortunately, yes.  Consider these two close points that have the same bounding box:

SELECT column1::box2d
FROM (VALUES
   ('POINT(0.123456789 0.123456789)'::geometry),
   ('POINT(0.123456788 0.123456788)'::geometry)) AS foo;

                                    column1
------------------------------------------------------------------------------
  BOX(0.123456783592701 0.123456783592701,0.123456791043282 0.123456791043282)
  BOX(0.123456783592701 0.123456783592701,0.123456791043282 0.123456791043282)
(2 rows)

So, using a group by on the bounding box will treat these two points will group them together, just like your linear 
example above.

If your dataset is of significant precision,  grouping by the hex string of the point works well.

Cheers,
Kevin




More information about the postgis-users mailing list