[postgis-users] st_collect returning more geometries than I want

Richard Greenwood richard.greenwood at gmail.com
Tue Jan 3 06:19:30 PST 2012


This seems so simple that I'm embarrassed to ask, but, putting my
pride in my pocket...

I want to aggregate two linestrings into one. The endpoint of the
first linestring is coincident with the start point of the second.
Using st_collect() or st_union() I get a multiLineString with 2
geometries. How can I get a single linestring, or a multiLineString
with just 1 geometry?

I cases where I aggregate linestrings that do not have coincident
start/end points I do want multiLineStrings with multiple geometries.

I tried the st_dump() "trick" with no better luck:

  SELECT label, st_numgeometries(ST_Collect (f.the_geom ))
  FROM ( SELECT label, (ST_Dump (wkb_geometry )).geom As the_geom
      from road_cl
    ) As f
  GROUP BY label

Basically I'm looking for the opposite of st_multi()

Thanks,
Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com



More information about the postgis-users mailing list