Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • recovering latitude and longitude of the observations having distances to a specific points

    Hello, I am dealing with a problem and I hope you can help me. I have 8000 observations from Germany in my dataset. I have the distance of these observations to port of Hamburg and Port of Bremen. I need to recover the latitude and longitude of each observation.
    I thought I could import the latitude and longitude of these two ports in my do file and recover the lat and lon of all the observations solving two nonlinear equations (Euclidean distance equation).

    I am aware of geo packages in stata that can recover lat and lon but since I do not have access to internet (strange, but it is what it is) while working with the data, I guess I need to actually solve a system of nonlinear equation.

    These are the geo coordinates of the ports:

    *reference coordinates
    *-------------------------------------------------------------------------------
    *Port of Bremen

    Bt= 53.09722 // latitude
    Bn= 8.75167 // longitude

    * distance to port of Bremen is variable "dis4"

    *Port of Hamburg

    Ht=53.52472 // latitude
    Hn=9.96333 // longitude


    * distance to port of Hamburg is "dist6"
    *--------------------------------------------------------------------------------

    Euclidean distances:

    lon= Bn + sqrt(dis4^2-(lat -Bt )^2)

    lon= Hn + sqrt(dis6^2-(lat -Ht )^2)

    this is a sample of the data:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long plz float(Dis4 Dis6)
    81248 580258.25  604684.2
    60315  331437.4  388282.9
    24988  184782.4 137974.06
    93185  514153.4  519856.5
    93489  512082.1 516745.75
    end

    Plz is the id. Since I do not have experience with mata or other functions that solve a system of nonlinear equations in stata I could not manage to obtain what I need. Could you please offer any help?
    Last edited by Tony Shayan; 04 Jan 2023, 01:12.

  • #2
    I'm probably mistaken here since this isn't my area of expertise, but don't you need to know the distance from a minimum of 3 points to get a single solution to your system of equations? If the first distance represents the radius of a circle around the port of Hamberg and the second distance represents the radius of a circle around the Port of Bremen, and you know your solution lies on both of these circles, then your solution is the intersection of the two circles, right? But isn't it possible that the circles overlap such that two different points intersect? In which case, how do you determine which intersection is the actual location of your point?

    Comment


    • #3
      Mr. Schaefer,

      Thanks for your comment. You are right. Three points are necessary to guarantee a unique solution. I solved the problem. The following link was helpful:

      https://math.stackexchange.com/quest...ree-other-know

      Comment

      Working...
      X