<div dir="ltr">I haven't got the "code" for this per se, but I guess you could use something like this as a data defined offset:<div><br></div><div><span style="font-family:monospace">to_string((100*cos("angle"))*-1)||','||to_string((100*sin("angle")*-1))</span><br><div><br></div><div>I feel the trick for a good result is to use the geometry generator for label placement. You could probably achieve similar results with expression defined offsets, but using the geometry generator will allow you to visualise where your label positions will end up, so tweaking will be much easier.</div><div><br></div><div>Basically this allows you to place labels at the generated geometry, which you can specify the location of using the trigonometric expression functions, and refine/ filter your results for specific outcomes.<div><br></div><div>I've put a screenshot showing the result on imgur [1] so you can have a look at what I mean. The red points will be the actual geometries and the smaller blue points are the positions created by the geometry generator.</div><div><br></div><div>I will provide the geometry generator expression I used below, but it's not "production grade" and I threw in everything including the kitchen sink to make it easy to modify, but I haven't actually worked out the trig you would need to accomplish what you want.</div><div><br></div><div><span style="font-family:monospace">with_variable('the_angle',<br>CASE<br>  WHEN "angle" >= 0 AND "angle" <= 90 THEN (90 - "angle")<br>  WHEN "angle" > 90 AND "angle" <= 180 THEN (90 - "angle" - 90)<br>  WHEN "angle" > 180 AND "angle" <= 270 THEN (90 - "angle" - 180)<br>  WHEN "angle" > 270 AND "angle" <= 360 THEN (90 - "angle" - 270)<br>  ELSE "angle"<br>END,<br>with_variable('my_offset', 200, <br>  make_point(<br>    with_variable('x_offset',<br>      CASE<br>        WHEN (@my_offset * cos(@the_angle)) >= 0 THEN (@my_offset * cos(@the_angle))<br>        ELSE (@my_offset * cos(@the_angle)) * -1<br>      END,<br>      $x - @x_offset),<br>    with_variable('y_offset',<br>      CASE<br>        WHEN (@my_offset * sin(@the_angle)) >= 0 THEN (@my_offset * sin(@the_angle))<br>        ELSE (@my_offset * sin(@the_angle)) * -1<br>      END,<br>      $y - @y_offset)<br>  )<br>))</span><br></div><div><br></div><div>Note that for "offset" labels, I know the rotation property isn't data defined but if you scroll down a little bit there is another data defined property for it.</div><div><br></div><div>I hope that is helpful, or at least provides a decent starting point for what you are after. There's always the label toolbar for modifying labels and callouts individually as well.</div><div><br></div><div>[1] <a href="https://imgur.com/a/JMR9w1h" target="_blank">https://imgur.com/a/JMR9w1h</a><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 2 Jul 2021 at 00:44, Tony Shepherd (FarmMaps NZ) <<a href="mailto:tony@farmmaps.nz" target="_blank">tony@farmmaps.nz</a>> 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="EN-NZ"><div><p class="MsoNormal">Hi All<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Simple question, but I am not sure how best to word it. Since we all love maps, I have a diagram below.<u></u><u></u></p><ol style="margin-top:0cm" start="1" type="1"><li style="margin-left:0cm">Create some points along a polyline. Easy using “Points along Gemoetry”<u></u><u></u></li><li style="margin-left:0cm">Display and label the points and put a rotation on the labels and  justify as needed (middle right in this case)<u></u><u></u></li></ol><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">What I want to do is shift the label out from the point slightly. That’s easy if using Offset X and Y, but it does exactly as expected and moves them X and Y, NOT accounting for the angle.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I’m guessing I would need to use Data Defined X and Y and do some trigonometry using the angle and distance to calculate the new preferred label position.  Does anybody have code to do this?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">A simple workaround I did use was to just pad a few spaces to the end of the label (ie “FIELD NAME” || ‘    ‘)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><img width="368" height="451" style="width: 3.8333in; height: 4.6979in;" id="gmail-m_-2812831886175532035gmail-m_-595490524573063032Picture_x0020_4" src="cid:17a67d1db984cff311"><u></u><u></u></p><p class="MsoNormal"><span>Cheers<u></u><u></u></span></p><p class="MsoNormal"><span>Tony<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="color:rgb(64,64,64)">Tony Shepherd</span></b><span style="color:rgb(89,89,89)">  </span><b><span>|</span></b><span style="color:rgb(89,89,89)">  GeoSpatial / Mapping Manager<u></u><u></u></span></p><p class="MsoNormal"><span style="color:rgb(89,89,89)">Ph 027 435 6193  </span><b><span>|</span></b><span style="color:rgb(89,89,89)">  E </span><a href="mailto:tony@farmmaps.nz" target="_blank"><span style="color:rgb(5,99,193)">tony@farmmaps.nz</span></a><span style="color:rgb(89,89,89)"><u></u><u></u></span></p><p class="MsoNormal"><span style="color:rgb(89,89,89)">FarmMaps NZ, 3 Kerwood Place, Gore 9740<u></u><u></u></span></p><p class="MsoNormal"><span style="color:rgb(89,89,89)"><u></u> <u></u></span></p><p class="MsoNormal"><a href="http://tonyshepherd8.wixsite.com/home" target="_blank"><b><span style="font-family:Arial,sans-serif;color:windowtext;text-decoration:none"><img border="0" width="157" height="34" style="width: 1.6354in; height: 0.3541in;" id="gmail-m_-2812831886175532035gmail-m_-595490524573063032Picture_x0020_1" src="cid:17a67d1db98692e332"></span></b></a><a href="https://www.wunderground.com/personal-weather-station/dashboard?ID=ISTLGORE2" target="_blank"><b><span style="font-family:Arial,sans-serif;color:windowtext;text-decoration:none"><img border="0" width="170" height="37" style="width: 1.7708in; height: 0.3854in;" id="gmail-m_-2812831886175532035gmail-m_-595490524573063032Picture_x0020_3" src="cid:17a67d1db987745b43"></span></b></a><b><span style="font-family:Arial,sans-serif"><u></u><u></u></span></b></p><p class="MsoNormal"><u></u> <u></u></p></div></div>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>