[Qgis-user] How to make diagonals

Dario C dario955i at gmail.com
Tue Feb 8 04:32:47 PST 2022


thank you. I'm gonna try. It looks I have just to select my layer and then
paste the code into python editor.
isn't it?

If so, do you have an idea how to choose also the second longest?

this is what I have in the code:

longest_line = max(all_lines, key=lambda x: x.length())


thanks again



Il giorno mar 8 feb 2022 alle ore 00:54 Sebastian Gutwein <bas at rdgland.com>
ha scritto:

> This stack exchange answer seems like it would work for you.
> https://gis.stackexchange.com/a/365955
>
> On Fri, Feb 4, 2022 at 11:33 AM chris hermansen <clhermansen at gmail.com>
> wrote:
>
>> Might generalizing the lines (Poiker Douglas or similar) yield four line
>> rectangles?
>>
>> On Thu, Feb 3, 2022, 23:44 Etienne Trimaille <etienne.trimaille at gmail.com>
>> wrote:
>>
>>> Maybe "oriented_bbox" to get first a proper rectangle ?
>>>
>>> https://docs.qgis.org/testing/en/docs/user_manual/expressions/functions_list.html#oriented-bbox
>>>
>>> But then, you might have some tiny leftover. It depends if you care or
>>> not.
>>>
>>> Otherwise, you need to use the angle at each points.
>>>
>>> I thought there is the longest line possible within a polygon, but I
>>> can't find it. I did it manually a few years ago.
>>>
>>> Le jeu. 3 févr. 2022 à 23:29, Dario C <dario955i at gmail.com> a écrit :
>>>
>>>> Hi,
>>>> I have several rectangles (almost squared) and I'd like to represent
>>>> their diagonals.
>>>>
>>>> I started to do with geometry generator with:
>>>> make_line(point_n($geometry,1),point_n($geometry,4))
>>>> and
>>>> make_line(point_n($geometry,2),point_n($geometry,5))
>>>>
>>>> Unfortunately, even if they look rectangular, actually they have more
>>>> then 4 points and, moreover, points do not always have the same order.
>>>>
>>>> here below an example:
>>>> [image: image.png]
>>>>
>>>> Is there any expression in order to pick the two longest segments
>>>> connecting all the points of the geometry?
>>>>
>>>>
>>>> Thanks
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> --
> Sent from a phone. Amazing! But possibly garbled. Sebastian Gutwein
> Regenerative Design Group 1 Chevalier Ave Greenfield MA Bas at rdgland.com
> (631) 241-1018
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220208/b48edbec/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 9834 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220208/b48edbec/attachment.png>


More information about the Qgis-user mailing list