Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: formatting latitude and longitude variables with sphdist

From   Kit Baum <>
Subject   re: st: formatting latitude and longitude variables with sphdist
Date   Fri, 2 Apr 2010 11:41:06 -0400

Tomeka said, in re Bill Rising's sphdist from SSC,

My question is:  How should the latitude and longitude measures be
formatted?  What is the best way to go about converting these variables
into the standard degree decimal notation.

First of all this is not a matter of formatting. In Stataspeak, formatting refers only to what the data look like when you print them out. It does not affect their contents. If you take 030500000 and convert it to numeric values, you need to create two variables, per help sphdist: lat1 = 30, lat2 = 30.  So extract the first three bytes and call their numeric equivalent lat1, and extract the next two bytes and multiply by 0.60 to get them in minutes. Call that variable lat2. If you want more precision, pull off more of the 5000000 piece, but it must be converted to minutes (or minutes and seconds).  Do the same for longitude, as sphdist requires (at least) two lat variables and two lon variables.

Kit Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index