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))),@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 <[email protected] <mailto:[email protected]>> 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 <[email protected]
    <mailto:[email protected]>> 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
    [email protected] <mailto:[email protected]>
    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

_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to