Saturday, 7 July 2018

How to get latitude /longitude in Degree Minute Second (DMS) using QGIS field calculator?


I have come up with the following expression to convert 5.1234 to 5° 7`24.24"


toint ($x) || '° ' || toint((($x) - toint ($x)) * 60) ||'`' || substr( (tostring(((($x) - toint ($x)) * 60) - toint((($x) - toint ($x)) * 60)) * 60),1,5) || '"'



Here’s the problem : for some points such as 5.1234, it works. but for others, it doesn’t. I suspect the problem is the integer conversion which round up the decimal figures instead of truncating it.


Is there any other option? thanks.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...