You're correct that this UoM is called decimal degrees, and partially correct that the value varies depending where you are on earth.
One degree of latitude is always about the same width. One degree of longitude varies depending on what latitude you're at. The accepted answer to this question explains it well: Calculating longitude length in miles?
Writing functions that are supposed to return a certain thing (or things) and can actually return something else is bad practice and can cause unexpected errors to creep in.
The standard way of doing this is to raise an exception with an informative message.
# Handle Python 2.x.
try:input = raw_input
def dms2dd(degrees, minutes, ...
I have a layer in OSGB coordinates (EPSG code 27700) and I can use to_dms(x(transform($geometry,'EPSG:4326','epsg:4326')), 'x', 3) to get a DMS representation of the point coordinates.
For example, I can use this expression in the labelling engine:
and my points get labelled with the DMS longitude, even though their coordinate system is still OSGB metres:
You should use the to_dms expression.
to_dms($x, 'x', 3)
If your geometry is not in EPSG:4326, reproject it on the fly, like this:
to_dms(x(transform($geometry,'EPSG:2154','EPSG:4326')), 'x', 3)
Source : http://changelog.qgis.org/en/qgis/version/3.4-LTR/#map-expressions