1

I'd like to know if there's a formula for calculating bearings of lines in degrees minutes seconds format. I already have been able to get the bearings in decimal degrees using:

CONCAT(format_number(degrees(azimuth(start_point($geometry), end_point($geometry))), 2), '°')
3

If you want to use an intermediate field containing the bearings in decimal degrees, I suggest not adding the '°' sign, but create a field "DEGREES" of type 'real' and populate it like this:

degrees(azimuth(start_point($geometry), end_point($geometry)))

Then, by using this field calculator expression in a new text field, you can format your angle in degrees, minutes, seconds:

concat(floor("DEGREES"), '° ', floor("DEGREES"*60 % 60), ''' ', "DEGREES"*3600 % 60, '''')

Or you could also do it with a single expression from the geometry directly:

concat(floor(degrees(azimuth(start_point($geometry), end_point($geometry)))), '° ', 
floor(degrees(azimuth(start_point($geometry), end_point($geometry)))*60 % 60), ''' ', 
degrees(azimuth(start_point($geometry), end_point($geometry)))*3600 % 60, '''')
  • Thank you @FSimardGIS, I've successfully derived the bearing in dms in the field calculator with your expression. Worked like magic – GeomaSmart Nov 26 '18 at 6:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.