[Qgis-user] Line dissolve

Nicolas Cadieux njacadieux.gitlab at gmail.com
Mon Aug 30 15:57:11 PDT 2021


Thanks Charles,

This will be very useful. Nice to know I'am not the only one going crazy 
with this!!!

Nicolas

On 2021-08-30 4:42 p.m., Charles Dixon-Paver wrote:
> I thought this would be easily solved with an expression but sadly I 
> haven't been able to get reliable results at all.
>
> My first thought was 
> collect($geometry,filter:=intersects($geometry,geometry(@parent))) and 
> when that didn't work I tried various aggregates and union operations 
> to no avail. Something like this might be useful if you can get it 
> into a usable form (I managed to get various multigeometries in the 
> form you are looking for but wasn't able to do much with them and 
> there seemed to be artifacts):
>
> collect_geometries(array_foreach(aggregate(layer:='lines',aggregate:='array_agg',expression:=$geometry,filter:=intersects($geometry,geometry(@parent))), at element))
>
> I was actually waiting for someone else to come up with a more elegant 
> solution, but it would probably also be possible to identify 
> intersecting features and get the minimum/ maximum feature id for 
> intersecting features with this:
>
> aggregate(layer:='lines',
> aggregate:='min',
> expression:="fid",
> filter:=intersects($geometry,geometry(@parent)))
>
> You could use that in the field calculator to create a field for 
> "grouping" various intersecting features to dissolve on, however it's 
> only going to identify the minimum of the currently intersecting 
> features so you would need to iterate through the process multiple 
> times. I can't think of an effective way to implement a "while" 
> conditional either.
>
> It's a pretty clanky way to do it, but if you are really struggling I 
> think it's possible.
>
> On Mon, 30 Aug 2021 at 22:10, Nicolas Cadieux 
> <njacadieux.gitlab at gmail.com <mailto:njacadieux.gitlab at gmail.com>> wrote:
>
>     Hi,
>
>     Seems like the plugin is available so I will try it out.  The
>     ability to create multi-linestring out of any touching lines
>     (touch here means intersects at the first or last node) would be
>     nice to have it if I can include it in a model.
>
>     My goal is for this model to work for anyone with a basic install
>     of QGIS LTR or 3.20 with minimal efforts so I am trying to
>     eliminate the need to rely on external plugins or scripts.
>
>     This is also my first attempt with models. It’s a learning curve
>     but I am having fun… I think this probably should have been a
>     plugin but my knowledge of GUI programming is basically 0.  That
>     will be for a next project…
>
>     Nicolas Cadieux
>     https://gitlab.com/njacadieux <https://gitlab.com/njacadieux>
>
>>     Le 30 août 2021 à 14:59, David Strip <qgis-user at stripfamily.net
>>     <mailto:qgis-user at stripfamily.net>> a écrit :
>>
>>      I looked at the source for this plug-in and as far as I can
>>     tell  it only merges lines that meet at endpoints. It ignores
>>     multi-lines, and only creates linestrings, so there are no
>>     vertices of degree >2 (ie, no junctions/forks). Also, the plug-in
>>     doesn't look for intersections between vertices (since it only
>>     looks to merge endpoints.)
>>     The StackExchange post appears to want multi-linestrings, which
>>     gives forks and such. Is that what you need?
>>
>>     On 8/30/2021 5:27 AM, Nicolas Cadieux wrote:
>>>     Hi,
>>>     This is the plugin I was referring to.  I don’t see it in the
>>>     current plugins (experimental turned on)  so I figured it’s QGIS
>>>     2 only.
>>>
>>>     https://github.com/ArMoraer/QGISMergeLines
>>>     <https://github.com/ArMoraer/QGISMergeLines>
>>>
>>>     Nicolas Cadieux
>>>     https://gitlab.com/njacadieux <https://gitlab.com/njacadieux>
>>>
>>
>     _______________________________________________
>     Qgis-user mailing list
>     Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>     <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>     <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>
-- 
Nicolas Cadieux
https://gitlab.com/njacadieux

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210830/5ff3f0e5/attachment.html>


More information about the Qgis-user mailing list