#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# HELP GPS convertion

edited May 2017

Hi, how to convert in Processing an Latitude and Longitude for example: 43.324 to 43° 32' 14'' 628.034 to 006° 28' 20''

Thank you a lot

Tagged:

• Your example is wrong :)
Step to convert from decimal degree to sexagesimal degree:
1) The integer part of decimal of degrees will remain the same.

2) Multiply the decimal by 60.
(i.e. 0.324 * 60 = 19.44)
The integer part becomes the minutes (i.e. 19').

3) Take the remaining decimal and multiply by 60. (i.e. 0.44 * 60 = 26.4)
The resulting number becomes the seconds (i.e. 26.4"). Seconds can remain as a decimal.
Solution: 43.324 --> 43° 19' 26.4"

Now you must format the output to get `043° 19' 26.4"`

• I'm sorry cameyo, but how to write this sysntax in processing ? I'm new in Processing

Regards, Fred

• Your conversion is not correct above. And the value for longitude is not correct. Check this: https://www.thoughtco.com/decimal-degrees-conversion-1434592

Here below is an example code to do the conversion.

Kf

``````String decimalDegToSexagesimalDeg(float inVal) {

float[] items=new float;
items=(int)inVal;                  //Extracts integer component
items= (int)((inVal-items)*60); //Remove integer, then multiply by 60 and return integer component
items=inVal-(items-items*60);//From main val, subtract item0 and item1*60 to get seconds

PVector p=new PVector((int)items,(int)items,items);
return "[ Deg., Min., Sec. ] = "+p.toString();
}

void setup(){

float lat=43.324;
println(decimalDegToSexagesimalDeg(lat));

}
``````
• kfrajer, thank you for your help