[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qgis-user
Subject:    Re: [Qgis-user] Batch selection/new feature creation
From:       Samuel Williams <sam.williams () sineenvironmental ! com>
Date:       2020-09-17 12:05:33
Message-ID: CABHCR0S_CKX7b4pSWdCHhTJLf0WsP8v6QFfEK5NiWpN7o7qTPg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/related)]

[Attachment #4 (multipart/alternative)]


Jeroen,
Thank you, that's a great approach that I hadn't thought of. I'll upload
the layer to postgres and do as you suggest!
Thanks again,


Sam.

Sam Williams

Director | *Sine Acoustics*
m. +447969123431 <%2B44%207969%20123431>|Sam.Williams@sineenvironmental.com
> www.sineenvironmental.com
Sine Acoustics is a trading name of Sine Environmental Limited, company
number 9609805. Postal address: 78 Old Church Road, Clevedon, North
Somerset, England, BS216PT.


On Thu, 17 Sep 2020 at 11:35, Groene Bij <mail@groenebij.nl> wrote:

> Hi,
> 
> 
> 
> Have you considered using postgis for this?
> 
> See:
> https://gis.stackexchange.com/questions/17495/dissolve-or-unsplit-lines-on-common-attributes-in-postgis-or-grass
>  
> 
> 
> First step would be to add the reference id from the spreadsheet to the
> polyline layer.
> 
> Polyline layer with the 100m stretches, "polyline"
> 
> 
> 
> Csv with sections, "tracks"
> 
> 
> 
> So, to add ref_id to each polyline you can use:
> 
> SELECT p.*, t.ref_id
> 
> FROM polyline as p
> 
> JOIN tracks as t
> 
> ON p.ch_1 >= t.start_ch AND p.ch_1 < t.end_ch
> 
> 
> 
> Than you can dissolve all polylines with the same ref_id like in the
> example link.
> 
> 
> 
> You can  combine al subqueries and export the result as new layer to your
> qgis-canvas.
> 
> 
> 
> That leaves the ‘saves these resulting new feature to an existing layer'
> part.
> 
> You can merge features from different layers into a new or existing layer.
> 
> 
> 
> Greetings,
> 
> Jeroen Hovens
> 
> 
> 
> 
> 
> *Van:* Qgis-user <qgis-user-bounces@lists.osgeo.org> *Namens *Samuel
> Williams
> *Verzonden:* donderdag 17 september 2020 11:14
> *Aan:* Qgis-user@lists.osgeo.org
> *Onderwerp:* [Qgis-user] Batch selection/new feature creation
> 
> 
> 
> Hello,
> I'm hoping that those with more experience of QIS might be able to help
> point me in the right direction.
> 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.).
> 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).
> 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.
> E.g.
> 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, populates the ID field from a field in the spreadsheet,
> and finally saves these resulting new feature to an existing layer.
> This process would then repeat for the other rows in the spreadsheet/csv.
> 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 way of
> using v.extract in batch mode which reads each of the required selections
> from the spreadsheet? 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.
> 
> Any help much appreciated!
> 
> Kind regards,
> 
> 
> 
> Sam.
> 
> Sam Williams
> 
> Director | *Sine Acoustics*
> m. +447969123431 <%2B44%207969%20123431>|
> Sam.Williams@sineenvironmental.com | www.sineenvironmental.com
> Sine Acoustics is a trading name of Sine Environmental Limited, company
> number 9609805. Postal address: 78 Old Church Road, Clevedon, North
> Somerset, England, BS216PT.
> 


[Attachment #7 (text/html)]

<div dir="ltr"><div class="gmail_default" \
style="font-family:tahoma,sans-serif;font-size:small;color:#444444"><span \
style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif">Jeroen,</span><br \
clear="all"></div><div class="gmail_default" \
style="font-family:tahoma,sans-serif;font-size:small;color:#444444"><span \
style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif">Thank you, \
that&#39;s a great approach that I hadn&#39;t thought  of. I&#39;ll upload the layer \
to postgres and do as you suggest!</span></div><div class="gmail_default" \
style="font-family:tahoma,sans-serif;font-size:small;color:#444444"><span \
style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif">Thanks \
again,</span></div><div><div dir="ltr" class="gmail_signature" \
data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><p \
style="margin-bottom:0cm;line-height:16px;color:rgb(0,0,0);font-family:&quot;Times \
New Roman&quot;;font-size:medium;font-style:normal;font-weight:400;letter-spacing:norm \
al;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></p><p \
style="margin-bottom:0cm;line-height:16px;color:rgb(0,0,0);font-family:&quot;Times \
New Roman&quot;;font-size:medium;font-style:normal;font-weight:400;letter-spacing:norm \
al;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font \
color="#444444"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2">Sam.</font></font></font></p><p \
style="margin-bottom:0cm;line-height:16px;color:rgb(0,0,0);font-family:&quot;Times \
New Roman&quot;;font-size:medium;font-style:normal;font-weight:400;letter-spacing:norm \
al;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font \
color="#4a442a"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2">Sam Williams</font></font></font></p><p \
style="margin-bottom:0cm;line-height:16px;color:rgb(0,0,0);font-family:&quot;Times \
New Roman&quot;;font-size:medium;font-style:normal;font-weight:400;letter-spacing:norm \
al;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font \
color="#000000"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2"><font color="#790014"><span lang="en-GB">Director</span></font><font \
color="#4a442a"><span lang="en-GB"><span>  </span>|<span>  </span></span></font><font \
color="#007965"><font face="Trebuchet MS, sans-serif"><span lang="en-GB"><b>Sine \
Acoustics</b></span></font></font></font></font></font><br><font \
color="#4a442a"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2"><span lang="en-GB">m.<span>  </span></span></font></font></font><font \
color="#1155cc"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2"><span lang="en-GB"><a href="tel:%2B44%207969%20123431" \
target="_blank">+447969123431</a></span></font></font></font><font \
color="#4a442a"><font face="Arial, sans-serif"><font style="font-size:10pt" \
size="2"><span lang="en-GB">|</span></font></font></font><a \
href="mailto:Sam.Williams@sineenvironmental.com" target="_blank"><font \
color="#1155cc"><span style="text-decoration:none"><font face="Arial, \
sans-serif"><font style="font-size:10pt" size="2"><span \
lang="en-GB">Sam.Williams@sineenvironmental.com</span></font></font></span></font></a><font \
color="#4a442a"><span style="text-decoration:none"><font face="Arial, \
sans-serif"><font style="font-size:10pt" size="2"><span lang="en-GB"><span>  \
</span></span></font></font></span></font><font color="#4a442a"><font face="Arial, \
sans-serif"><font style="font-size:10pt" size="2"><span lang="en-GB">|<span>  \
</span></span></font></font></font><a href="http://www.sineenvironmental.com/" \
target="_blank"><font color="#1155cc"><span style="text-decoration:none"><font \
face="Arial, sans-serif"><font style="font-size:10pt" size="2"><span \
lang="en-GB">www.sineenvironmental.com</span></font></font></span></font></a><br><font \
face="Arial, sans-serif"><font style="font-size:7pt" size="1"><font \
color="#4a442a"><span lang="en-GB">Sine Acoustics is a trading name of Sine \
Environmental Limited, company number  </span></font><font color="#4a442a">9609805. \
Postal address: 78 Old Church Road, Clevedon, North Somerset, England, \
BS216PT.</font></font></font></p></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 17 Sep 2020 at 11:35, \
Groene Bij &lt;<a href="mailto:mail@groenebij.nl">mail@groenebij.nl</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="NL"><div \
class="gmail-m_-2851193728100670803WordSection1"><p \
class="MsoNormal"><span>Hi,<u></u><u></u></span></p><p \
class="MsoNormal"><span><u></u>  <u></u></span></p><p class="MsoNormal"><span \
lang="EN-US">Have you considered using postgis for this?<u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">See: <a \
href="https://gis.stackexchange.com/questions/17495/dissolve-or-unsplit-lines-on-common-attributes-in-postgis-or-grass" \
target="_blank">https://gis.stackexchange.com/questions/17495/dissolve-or-unsplit-lines-on-common-attributes-in-postgis-or-grass</a><u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">First step would be to add the reference id from \
the spreadsheet to the polyline layer.<u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">Polyline layer with the 100m stretches, \
"polyline"<u></u><u></u></span></p><p class="MsoNormal"><img border="0" width="193" \
height="261" style="width: 2.0104in; height: 2.7187in;" \
id="gmail-m_-2851193728100670803Afbeelding_x0020_3" \
src="cid:1749bf3a4cb855d351"><span lang="EN-US"><u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">Csv with sections, \
"tracks"<u></u><u></u></span></p><p class="MsoNormal"><img border="0" width="193" \
height="101" style="width: 2.0104in; height: 1.052in;" \
id="gmail-m_-2851193728100670803Afbeelding_x0020_2" \
src="cid:1749bf3a4cb9374b62"><span lang="EN-US"><u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">So, to add ref_id to each polyline you can \
use:<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">SELECT p.*, \
t.ref_id<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">FROM \
polyline as p<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">JOIN \
tracks as t<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">ON p.ch_1 \
&gt;= t.start_ch AND p.ch_1 &lt; t.end_ch<u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">Than you can dissolve all polylines with the \
same ref_id like in the example link.<u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">You can   combine al subqueries and export the \
result as new layer to your qgis-canvas.<u></u><u></u></span></p><p \
class="MsoNormal"><span lang="EN-US"><u></u>  <u></u></span></p><p \
class="MsoNormal"><span lang="EN-US">That leaves the ‘</span><span lang="EN-US" \
style="color:rgb(68,68,68)">saves these resulting </span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span lang="EN-US" \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">new \
</span></span><span lang="EN-US" style="color:rgb(68,68,68)">feature to </span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span lang="EN-US" \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">an</span></span><span \
lang="EN-US" style="color:rgb(68,68,68)">  existing layer' \
part.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">You can merge \
features from different layers into a new or existing \
layer.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u>  \
<u></u></span></p><p class="MsoNormal"><span \
lang="EN-US">Greetings,<u></u><u></u></span></p><p class="MsoNormal"><span \
lang="EN-US">Jeroen Hovens<u></u><u></u></span></p><p class="MsoNormal"><span \
lang="EN-US"><u></u>  <u></u></span></p><p class="MsoNormal"><span \
lang="EN-US"><u></u>  <u></u></span></p><div \
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid \
rgb(225,225,225);padding:3pt 0cm 0cm"><p class="MsoNormal"><b>Van:</b> Qgis-user \
&lt;<a href="mailto:qgis-user-bounces@lists.osgeo.org" \
target="_blank">qgis-user-bounces@lists.osgeo.org</a>&gt; <b>Namens </b>Samuel \
Williams<br><b>Verzonden:</b> donderdag 17 september 2020 11:14<br><b>Aan:</b> <a \
href="mailto:Qgis-user@lists.osgeo.org" \
target="_blank">Qgis-user@lists.osgeo.org</a><br><b>Onderwerp:</b> [Qgis-user] Batch \
selection/new feature creation<u></u><u></u></p></div><p class="MsoNormal"><u></u>  \
<u></u></p><div><p class="MsoNormal"><span \
style="color:rgb(68,68,68)">Hello,<br>I&#39;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="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)"> populates \
the ID field from a field in the spreadsheet,</span></span><span \
style="color:rgb(68,68,68)"> and</span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)"> \
finally</span></span><span style="color:rgb(68,68,68)"> saves these resulting \
</span><span class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">new \
</span></span><span style="color:rgb(68,68,68)">feature to </span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">an</span></span><span \
style="color:rgb(68,68,68)">  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="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">way of using \
v.extract in </span></span><span style="color:rgb(68,68,68)">batch</span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)"> mode which \
reads each of the required selections from</span></span><span \
style="color:rgb(68,68,68)">  the spreadsheet?</span><span \
class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)"> From the \
grass manual v.extract appears to read selections from a text file, but I can&#39;t \
find any good examples, or detail in the manual on the required format for the text \
file.</span></span><u></u><u></u></p><div><p class="MsoNormal"><span \
class="gmail-m_-2851193728100670803gmaildefault"><span \
style="font-size:12pt;font-family:Tahoma,sans-serif;color:rgb(68,68,68)">Any help \
much appreciated!   </span></span><u></u><u></u></p><div><div><div><div><div><div><div><div><div><div><div><div><div><div><p \
style="margin-bottom:0cm;line-height:12pt"><span \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(68,68,68)">Kind \
regards,</span><span style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><u></u><u></u></span></p><p \
style="margin-bottom:0cm;text-align:start;word-spacing:0px"><span \
style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><u></u>  <u></u></span></p><p \
style="margin-bottom:0cm;line-height:12pt;text-align:start;word-spacing:0px"><span \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(68,68,68)">Sam.</span><span \
style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><u></u><u></u></span></p><p \
style="margin-bottom:0cm;line-height:12pt;text-align:start;word-spacing:0px"><span \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(74,68,42)">Sam \
Williams</span><span style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><u></u><u></u></span></p><p \
style="margin-bottom:0cm;line-height:12pt;text-align:start;word-spacing:0px"><span \
lang="EN-GB" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(121,0,20)">Director</span><span \
lang="EN-GB" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(74,68,42)"> \
|  </span><b><span lang="EN-GB" style="font-size:10pt;font-family:&quot;Trebuchet \
MS&quot;,sans-serif;color:rgb(0,121,101)">Sine Acoustics</span></b><span \
style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><br></span><span lang="EN-GB" \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(74,68,42)">m.  \
</span><span lang="EN-GB" \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(17,85,204)"><a \
href="tel:%2B44%207969%20123431" target="_blank">+447969123431</a></span><span \
lang="EN-GB" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(74,68,42)">|</span><span \
style="font-size:13.5pt;font-family:&quot;Times New Roman&quot;,serif;color:black"><a \
href="mailto:Sam.Williams@sineenvironmental.com" target="_blank"><span lang="EN-GB" \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(17,85,204);text-decoration:none">Sam.Williams@sineenvironmental.com</span></a></span><span \
lang="EN-GB" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(74,68,42)"> \
|  </span><span style="font-size:13.5pt;font-family:&quot;Times New \
Roman&quot;,serif;color:black"><a href="http://www.sineenvironmental.com/" \
target="_blank"><span lang="EN-GB" \


["image005.png" (image/png)]
["image006.png" (image/png)]
[Attachment #10 (text/plain)]

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic