<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:x="urn:schemas-microsoft-com:office:excel" 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 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@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:"Trebuchet MS";
panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.gmaildefault
{mso-style-name:gmail_default;}
span.E-mailStijl20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
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 lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Have you considered using postgis for this?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>See: <a href="https://gis.stackexchange.com/questions/17495/dissolve-or-unsplit-lines-on-common-attributes-in-postgis-or-grass">https://gis.stackexchange.com/questions/17495/dissolve-or-unsplit-lines-on-common-attributes-in-postgis-or-grass</a><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>First step would be to add the reference id from the spreadsheet to the polyline layer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Polyline layer with the 100m stretches, “polyline”<o:p></o:p></span></p><p class=MsoNormal><img border=0 width=193 height=261 style='width:2.0104in;height:2.7187in' id="Afbeelding_x0020_3" src="cid:image005.png@01D68CEF.07F22370"><span lang=EN-US style='mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Csv with sections, “tracks”<o:p></o:p></span></p><p class=MsoNormal><img border=0 width=193 height=101 style='width:2.0104in;height:1.052in' id="Afbeelding_x0020_2" src="cid:image006.png@01D68CEF.07F22370"><span lang=EN-US style='mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>So, to add ref_id to each polyline you can use:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>SELECT p.*, t.ref_id<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>FROM polyline as p<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>JOIN tracks as t<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>ON p.ch_1 >= t.start_ch AND p.ch_1 < t.end_ch<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Than you can dissolve all polylines with the same ref_id like in the example link.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>You can combine al subqueries and export the result as new layer to your qgis-canvas.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>That leaves the ‘</span><span lang=EN-US style='color:#444444'>saves these resulting </span><span class=gmaildefault><span lang=EN-US style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>new </span></span><span lang=EN-US style='color:#444444'>feature to </span><span class=gmaildefault><span lang=EN-US style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>an</span></span><span lang=EN-US style='color:#444444'> existing layer’ part.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>You can merge features from different layers into a new or existing layer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Greetings,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Jeroen Hovens<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b>Van:</b> Qgis-user <qgis-user-bounces@lists.osgeo.org> <b>Namens </b>Samuel Williams<br><b>Verzonden:</b> donderdag 17 september 2020 11:14<br><b>Aan:</b> Qgis-user@lists.osgeo.org<br><b>Onderwerp:</b> [Qgis-user] Batch selection/new feature creation<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span style='color:#444444'>Hello,<br>I'm hoping that those with more experience of QIS might be able to help point me in the right direction.<br>I have a layer consisting of around 700 end-to-end polylines, each of which represents a 100m stretch of railway track centreline. Each polyline is attributed with an integer value which represents its starting chainage (distance in m from the start of the railway line, abbreviated ch.).<br>I also have a spreadsheet/csv with several hundred rows, each of which represents a different section of the railway. These sections are defined by their start and end chainage (e.g. ch. 1300 to ch. 1800 would be a 500m stretch starting 1300m from the beginning of the line).<br>I am looking for an efficient way to select each of the polylines associated with each row in the spreadsheet, dissolve them (they should touch end to end), and then save them as a new feature on an existing layer. Each one will need to be given a reference ID from the relevant line in the spreadsheet.<br>E.g.<br>Row 1 of spreadsheet selects all polylines with a starting chainage 1300 to 1700 (which with 100m segments selects the whole length 1300-1800), dissolves them,</span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'> populates the ID field from a field in the spreadsheet,</span></span><span style='color:#444444'> and</span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'> finally</span></span><span style='color:#444444'> saves these resulting </span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>new </span></span><span style='color:#444444'>feature to </span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>an</span></span><span style='color:#444444'> existing layer.<br>This process would then repeat for the other rows in the spreadsheet/csv.<br>I’ve got a reasonable understanding of python, but have never tried using it within qgis. Would that be the easiest route, or is there a </span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>way of using v.extract in </span></span><span style='color:#444444'>batch</span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'> mode which reads each of the required selections from</span></span><span style='color:#444444'> the spreadsheet?</span><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'> From the grass manual v.extract appears to read selections from a text file, but I can't find any good examples, or detail in the manual on the required format for the text file.</span></span><o:p></o:p></p><div><p class=MsoNormal><span class=gmaildefault><span style='font-size:12.0pt;font-family:"Tahoma",sans-serif;color:#444444'>Any help much appreciated! </span></span><o:p></o:p></p><div><div><div><div><div><div><div><div><div><div><div><div><div><div><p style='margin-bottom:0cm;line-height:12.0pt'><span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#444444'>Kind regards,</span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><o:p></o:p></span></p><p style='margin-bottom:0cm;mso-line-height-alt:12.0pt;text-align:start;word-spacing:0px'><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><o:p> </o:p></span></p><p style='margin-bottom:0cm;line-height:12.0pt;text-align:start;word-spacing:0px'><span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#444444'>Sam.</span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><o:p></o:p></span></p><p style='margin-bottom:0cm;line-height:12.0pt;text-align:start;word-spacing:0px'><span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#4A442A'>Sam Williams</span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><o:p></o:p></span></p><p style='margin-bottom:0cm;line-height:12.0pt;text-align:start;word-spacing:0px'><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#790014'>Director</span><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#4A442A'> | </span><b><span lang=EN-GB style='font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#007965'>Sine Acoustics</span></b><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><br></span><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#4A442A'>m. </span><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#1155CC'><a href="tel:%2B44%207969%20123431" target="_blank">+447969123431</a></span><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#4A442A'>|</span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><a href="mailto:Sam.Williams@sineenvironmental.com" target="_blank"><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#1155CC;text-decoration:none'>Sam.Williams@sineenvironmental.com</span></a></span><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#4A442A'> | </span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><a href="http://www.sineenvironmental.com/" target="_blank"><span lang=EN-GB style='font-size:10.0pt;font-family:"Arial",sans-serif;color:#1155CC;text-decoration:none'>www.sineenvironmental.com</span></a><br></span><span lang=EN-GB style='font-size:7.0pt;font-family:"Arial",sans-serif;color:#4A442A'>Sine Acoustics is a trading name of Sine Environmental Limited, company number </span><span style='font-size:7.0pt;font-family:"Arial",sans-serif;color:#4A442A'>9609805. Postal address: 78 Old Church Road, Clevedon, North Somerset, England, BS216PT.</span><span style='font-size:13.5pt;font-family:"Times New Roman",serif;color:black'><o:p></o:p></span></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></body></html>