Hello, Thank you very much this works fine.
You taught me two major things I didn't know. First I had re-invented the wheel with my geometry_sum function with was plainly what st_collect did in a much faster way. Second, I had never use ST_linemerge which does a true merge of line strings, not simply making a multilinstring of them. I was afraid that adding all the lines and then split them would take a huge lot of time but actually it was very fast ! With your tips I have strongly improved my treatments. Thank you very much Nicolas. -----Message d'origine----- De : [email protected] [mailto:[email protected]] De la part de Arnaud Lesauvage Envoyé : mercredi 30 décembre 2009 15:20 À : [email protected] Objet : Re: [postgis-users] linestring aggregation Le 29/12/2009 11:39, Nicolas Gillet - MARKET-IP a écrit : > 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); Nicolas, what does your geometry_sum function do precisely ? There is a ST_Linemerge function that takes a collection of linestrings as an argument and merges them together into a multilinestring. Maybe it doesn't give you the result you expect ? With a table "thetable" having an "attrib" field and a "geom" field, I would write the query like this : SELECT attrib, (st_dump(merged_geom)).geom FROM ( SELECT attrib, ST_Linemerge(ST_Collect(geom)) AS merged_geom FROM thetable GROUP BY attrib ) AS subq; Does this solve your problem ? Regards, Arnaud _______________________________________________ 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
