# Peter Lux

## Converting Radians in Degrees Latitude and Longitude

The task of converting radians to degrees is reasonably trivial. However, latitudes and longitudes are usually expressed in the range -90 to 90 for longitude and -180 to 180 for latitudes.
This is only a convention – latitudes above 90 have real unique meaning and they should not create any problems in google maps etc. However, when displaying latitude, longitudes as text it is best to use this convention.

http://en.wikipedia.org/wiki/Geographic_coordinate_system)

## Angles Greater than 360

We just need to take of 360Â° – for example 390Â° is the same as 30Â°. We may also have to handle angles such as 1000Â°.

## Latitude

Everything from 0 to 90Â° is as it is. However, 120Â° is the same as 60Â° and 150Â° is the same as 30Â° and 180Â° is the same as 0Â°. Anything above 180Â° is expressed as a negative angle i.e. 190Â° is -10Â° etc.

Coordinates 0 to -90Â° are as they are. However, -120Â° is the same as -60Â° and -150Â° is the same as -30Â°.

## Longitude

Angles are usually expressed in the range -180Â° to 180Â°. 190Â° is the same as -170Â°, 210Â° is the same as -150Â° until 380Â° which is the same as 0Â°.

## The Javascript Code

```
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748    // convert radians into latitude
// 90 to -90
// first of all get everthing into the range -2pi to 2pi

// convert negatives to equivalent positive angle

// restict to 0 - 180

// anything above 90 is subtracted from 180
// if it is greater than 180 then make negative
else

}

// 180 to -180
// first of all get everthing into the range -2pi to 2pi

// convert negatives to equivalent positive angle

// anything above 90 is subtracted from 360

// if it is greater than 180 then make negative
else

}

```

### 2 Responses to “Converting Radians in Degrees Latitude and Longitude”

• Lester Hanger says:

Hi Pete,

Just noticed a typo in your intro: “latitudes and longitudes are usually expressed in the range -90 to 90 for longitude and -180 to 180 for latitudes”

Should be -90 to 90 for LATITUDE not LONGITUDE.

• Richard says:

Hi, good article, I think you made minor mistake in the first paragraph:
latitudes and longitudes are usually expressed in the range -90 to 90 for longitude and -180 to 180 for latitudes.