I think you have to pull it out in the WHERE clause.

I'm not sure if this will work, I'm not good at doing SQL in my head
and can't test it right now:

SELECT name, code, geometry_sum(r1.the_geom)
FROM roads r1, roads r2
WHERE ST_Touches(r1.the_geom, r2.the_geom)
GROUP BY name, code

and you'll probably have to UNION this with a query that gets the
pieces that don't touch.

   Sean

On Dec 29, 9:42 am, "Nicolas Gillet - MARKET-IP"
<[email protected]> wrote:
> Hello
>
> Thanks for the answer,
>
> I knew about ST_touches(geometry, geometry) function.
>
> But I don't know how to use it in my aggregate query to group only the
> records that are touching each other
>
> SELECT name, code, geometry_sum(the_geom) FROM roads
> GROUP BY name, code, st_touches(???, the_geom)
>
> Or something like that (geometry_sum being my aggregate function).
>
> Any idea ?
>
> Nicolas
>
> -----Message d'origine-----
> De : [email protected]
> [mailto:[email protected]] De la part de Sean
> Envoyé : mardi 29 décembre 2009 15:34
> À : [email protected]
> Objet : Re: [postgis-users] linestring aggregation
>
> Sounds like ST_Touches:http://postgis.refractions.net/docs/ST_Touches.html
>
>   Sean
>
> On Dec 29, 5:39 am, "Nicolas Gillet - MARKET-IP"
>
> <[email protected]> wrote:
> > Hello
>
> > I am trying to aggregate linestrings together based on their attributes
> and
> > the fact that they are touching each other.
>
> > Therefore I found out how to write a very basic aggregate function :
>
> >    CREATE AGGREGATE geometry_sum (
>
> >                 SFUNC = st_union,
>
> >                 BASETYPE = geometry,
>
> >                 STYPE = geometry);
>
> > I can now aggregate my linestrings grouped by their names, importance, and
> > so on but . I have trouble to group them by the fact that they are
> touching
> > each other.
>
> > e.g.
>
> > linestring A, B and C have the same attributes but only A and B are
> touching
> > each other.
>
> > I would like as a result A+B in one record, and C in a second record.
>
> > Does someone have any tips to share ?
>
> > Thank you,
>
> > Nicolas
>
> > _______________________________________________
> > postgis-users mailing list
>
> [email protected]http://postgis.refractions.net/mailman/
> listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> [email protected]http://postgis.refractions.net/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> [email protected]http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to