# 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.