# Tutorial: Degrees, Radians and Minutes

The coordinates returned from the Geolake API are a latitude and longitude in degrees in decimal form.
The latitude is 0 at the Equator and goes to +90 at the North Pole and -90 at the South Pole.
The longitude is 0 at Greenwich, England and goes down to the west to -180 and up to the east to +180.

In some cases, it might be more convenient to work with the coordinates in radians, or in degrees with minutes and seconds, for example:

`1° 45' 30" S, 2° 30' 40" E`

## Decimals vs Minutes and Seconds

The Geolake API returns value in decimal degrees. In decimals, the value halfway between 1 degree and 2 degrees is simply 1.5 degrees.

Another popular notation for coordinates uses minutes and seconds, where the value halfway between 1 and 2 degrees is 1 degree and 30 minutes.
This is usually shown in the format: `1° 45' 30" S`

, meaning 1 degree, 45 minutes and 30 seconds in the southern hemisphere.

Decimal coordinates can also be negative. When coordinates are shown with minutes and seconds, they are usually not positive or negative, but rather indicated by a wind direction.

`Latitudes: positive is N, negative is S`

`Longitudes: positive is E, negative is W`

The conversion from decimals to minutes and seconds is simple:

`1 degree = 60 minutes`

`1 minute = 60 seconds`

### Javascript conversion

```
/*
* Convert decimal degrees to degrees, minutes and seconds.
* @param decimalDegrees Coordinate in decimal degrees, as returned from the Geolake API
* @param isLatitude True for latitudes, false for longitudes
* @return Formatted coordinate
*/
function decimalToMinutes(decimalDegrees, isLatitude) {
var absDegrees = Math.abs(decimalDegrees);
var degrees = Math.floor(absDegrees);
absDegrees -= degrees;
var minutes = Math.floor(absDegrees * 60);
absDegrees -= minutes / 60;
var seconds = Math.floor(absDegrees * 3600);
var suffix = "";
if(isLatitude) {
suffix = decimalDegrees >= 0 ? "N" : "S";
} else {
suffix = decimalDegrees >= 0 ? "E" : "W";
}
var formattedDegrees = degrees + "\u00B0 " + minutes + "'' " + seconds + "\" " + suffix;
alert(formattedDegrees);
}
decimalToMinutes(-1.234567, true);
// Output: 1° 14' 4" S
```

## Radians

Degrees on a circle go from 0 to 360, and radians from 0 to 2 * Pi.
Latitudes are -90 to +90 degrees, and -0.5 * Pi to +0.5 * Pi radians.
Longitudes are -180 to +180 degrees, and -Pi to +Pi radians.

To convert to decimal degrees returned by the Geolake API, and the other way around:

`radians = degrees * PI / 180`

`degrees = radians * 180 / PI`