5

In Geometry Generator in Symbology in Layer Properties, the following expression works, but the result is not satisfactory due to the middle point fixed coefficient 1,1:

make_line (
     start_point(make_point("Origin Longitude", "Origin Latitude")), 
     translate(centroid($geometry), 1, 1), 
     end_point(make_point("Dest Longitude", "Dest Latitude")))

Using the $length function as below doesn't work. Why no lines are displayed?

make_line (
     start_point(make_point("Origin Longitude", "Origin Latitude")), 
     translate(centroid($geometry), $length, $length),
     end_point(make_point("Dest Longitude", "Dest Latitude")))

Using the length() function as below works, but while some lines are displayed OK (e.g. India -> Bangladesh), some are way too curvy (e.g. Bangladesh -> India). How can I make all of them just slightly curved like the India -> Bangladesh one?

make_line(
     start_point(make_point("Origin Longitude", "Origin Latitude")), 
     translate(centroid($geometry), 
     length(
           make_line(
                make_point("Origin Longitude", "Origin Latitude"), 
                make_point("Dest Longitude", "Dest Latitude")
           )
     )/5000000,
     length((
           make_line(
                make_point ("Origin Longitude", "Origin Latitude"), 
                make_point("Dest Longitude", "Dest Latitude")
                )
     ))/5000000), 
     end_point(make_point("Dest Longitude", "Dest Latitude"))
)

QGIS version: 3.4.6

example

  • A manual work around would be to adjust them using node select. I use that approach to do flow maps....and applaud you for having a solution which gets most of the lines curved programmatically! – Andrew Tice Sep 25 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.