Skip to main content
deleted 28 characters in body; edited tags; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

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

I have come up with the following expression to convert 5.1234 to 5° 7`24to 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) || '"'

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 for some points such as 5.1234, it works. butBut for others, itit doesn’t. II suspect the problem is the integer conversion which round up the decimal figures instead of truncating it.

Is there any other option? thanks.

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.

Getting 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?

Tweeted twitter.com/StackGIS/status/1216329165693165570
deleted 86 characters in body
Source Link
Obsidianz
  • 119
  • 1
  • 8

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.

Sorry If this is a known bug, new convert here. My previous religion was the Arc. IsIs there any other option? thanks.

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.

Sorry If this is a known bug, new convert here. My previous religion was the Arc. Is there any other option? thanks.

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.

Source Link
Obsidianz
  • 119
  • 1
  • 8

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.

Sorry If this is a known bug, new convert here. My previous religion was the Arc. Is there any other option? thanks.