Bookmark and Share

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


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

re: st: formatting latitude and longitude variables with sphdist


From   Kit Baum <[email protected]>
To   [email protected]
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   |   http://ideas.repec.org/e/pba1.html
                              An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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