Convert Latitude / Longitude in Degree/Radians? Convert Latitude / Longitude in Degree/Radians? ios ios

Convert Latitude / Longitude in Degree/Radians?


Since Latitude and Longitude are measured in degrees, you can use the following formula to convert to radians, and back to degrees:

Radians = Degrees * PI / 180

and on the inverse,

Degrees = Radians * 180 / PI


If you look at earth like a sphere, latitude and longitude are already given in units of degrees. Longitude is expressed as -180 degrees (-pi radians) to 180 degrees (pi radians) with 0 degrees centered at the prime meridian. Latitude is expressed as -90 degrees (-pi/2 radians) to 90 degrees (pi/2 radians) with respect to the equator. This is already a spherical coordinate system (depending on the caveats I give below) with earth's radius approximately 6371 km.

So just convert by multiplying by pi/180 as you would for convert degrees to radians in any normal sense. If you want to use those radians for doing something specific like calculating distances between two lat/lons then you should look at some pre-existing sources.

Similar questions have been asked before, i.e. Convert Lat-Lon to Cartesian Coordinates.

Generally speaking, the 'correct' answer for a lot of conversion quesitons depends on what error is acceptable in your answer (can it be off 1 mile for distances of 20 miles, etc.) and the model of the world is appropriate in your problem domain. The world is better approximated by an ellipsoid (squashed sphere) than a sphere, but it is easier to perform the calculations assuming earth is a sphere and the error introduced can be minimal. Especially if your program is just looking for 'rough' answers that won't be used for, say, engineering projects.

It is likely that the lat-lons you have are given in a coordinate system called WGS-84 which is what most hardware GPS units use, which assumes an ellipsoid model.

Note that I had a lot more sources, but I guess I have low reputation so I can only post two links. I would suggest reading on wikipedia about WGS-84, earth's radius, spherical coordinates, prime meridian, and equator for some visual references.