Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

re: st: formatting latitude and longitude variables with sphdist


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index