Skip to content

Instantly share code, notes, and snippets.

@agiudiceandrea
Last active October 10, 2021 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agiudiceandrea/a61377b1c9940c4bfeb3f7d7fa1fd48d to your computer and use it in GitHub Desktop.
Save agiudiceandrea/a61377b1c9940c4bfeb3f7d7fa1fd48d to your computer and use it in GitHub Desktop.
Expression to calculate bearing true-north based (loxodromic) between first and second point from current layer with UTM coordinates
-- by Andrea Giudiceandrea licensed under CC-BY-SA 4.0 license
degrees(
azimuth(geometry(get_feature_by_id(@layer, 1)), geometry(get_feature_by_id(@layer, 2))) -
-- the grid convergence from https://gis.stackexchange.com/a/394982/107272 by Houska
with_variable('LL', transform( geometry(get_feature_by_id(@layer, 1)),layer_property(@layer,'crs'),'EPSG:4326'),
with_variable('displacedLL',translate(@LL,0,0.001),
azimuth(geometry(get_feature_by_id(@layer, 1)),transform(@displacedLL,'EPSG:4326',layer_property(@layer,'crs')))
))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment