<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-US link=blue vlink=purple><div class=WordSection1><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> qgis-user-bounces@lists.osgeo.org [mailto:qgis-user-bounces@lists.osgeo.org] <b>On Behalf Of </b>Micha Silver<br><b>Sent:</b> Friday, June 08, 2012 3:13 PM<br><b>To:</b> magerlin<br><b>Cc:</b> qgis-user@lists.osgeo.org<br><b>Subject:</b> Re: [Qgis-user] "Dissolve" a line layer?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 08/06/2012 09:30, magerlin wrote: <o:p></o:p></p><pre>I've got a road network which is broken down to a lot of very short sections.<o:p></o:p></pre><pre>Theese I would like to join by the road name to just get one feature per<o:p></o:p></pre><pre>road name.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>If it had been a polygon layer I could have used the Vector - Geoprocessing<o:p></o:p></pre><pre>- Dissolve tool, but it is only for polygons.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I am aware that I can do it manually either 2 sections at a time by the<o:p></o:p></pre><pre>"Join two lines" plugin or more sections at a time by using the "Merge<o:p></o:p></pre><pre>selected features" button in the Advanced Digitizing toolbar. But there are<o:p></o:p></pre><pre>far to many sections to do this by hand....<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Any suggestions?<o:p></o:p></pre><p class=MsoNormal><br>If you're willing to work with spatialite, then you can do this with a query as follows:<br>(Assuming you have a roads shape file, with columns "road_id", and  "road_name")<br><br>spatialite> .loadshp roads.shp roads LATIN1 4326<br>spatialite> CREATE TABLE roads_merged (road_id integer primary key, road_name text);<br>spatialite> SELECT AddGeometryColumn('roads_merged', 'Geometry', 4326, 'MULTILINESTRING', 'XY');<br>spatialite> INSERT INTO roads_merged (road_id, road_name, Geometry) <br>        SELECT road_id, road_name, CastToMulti(GUnion(Geometry))<br>        FROM roads<br>        GROUP BY road_name;<br><br>The first line loads a shapefile into spatialite, with LATIN1 encoding and EPSG code 4326 (Lon/Lat WGS84)<br>The second creates a new empty table for the merged roads, and the third makes this new table spatial, accepting geometry types MULTILINESTRING, and also EPSG 4326.<br>The last line, the INSERT uses GROUP BY to merge the rows from the original table with the same road name. And the GUnion() function merges the line segment's geometry into MULTILINESTRING features. (CastToMulti to make sure...)<br><br>Give it a try,<br>Micha<br><br><br><br><o:p></o:p></p><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>-----<o:p></o:p></pre><pre>Regards Morten<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Qgis 1.7.4 Stand alone installer in Win7 64 bit<o:p></o:p></pre><pre>--<o:p></o:p></pre><pre>View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Dissolve-a-line-layer-tp4979880.html">http://osgeo-org.1560.n6.nabble.com/Dissolve-a-line-layer-tp4979880.html</a><o:p></o:p></pre><pre>Sent from the Quantum GIS - User mailing list archive at Nabble.com.<o:p></o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Qgis-user mailing list<o:p></o:p></pre><pre><a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><o:p></o:p></pre><pre><a href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre><pre><o:p> </o:p></pre><pre>This mail was received via Mail-SeCure System.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[JM] I just installed spacialite and I’m very intrigued by what you did there, Micha, but now my question.<o:p></o:p></span></i></b></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Where can I read up on all the commands for spacialite? What’s the best way to learn all that stuff  </span></i></b><b><i><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span></i></b><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><br>Thanks<o:p></o:p></span></i></b></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Jake<o:p></o:p></span></i></b></p></div></div></body></html>