Announcement

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

  • Calculating distance with xy coordinates

    Hi all,

    I am trying to calculate distance, but my data is in xycoordinates (for example 260751,471352). Does anyone know how I can change them to longitude and latitude? Or does anyone know which command I can use to calculate distance with these coordinates?

    Thank you very much

  • #2
    If your data are in (x,y) coordinates, the distances between points are given by Pythagoras' theorem. Why on Earth (pun intended) would you want to convert to latitude and longitude first? The presumption with such coordinates is that points are near enough for Earth curvature not to matter.

    A more crucial question is what data structure you have and what you want. In general, an n by 2 structure of point pairs could yield an n x n matrix of distances.
    Last edited by Nick Cox; 21 Apr 2016, 05:35.

    Comment


    • #3
      So I have 218.000 observations with different xy coordinates. And I want to calculate their distance to one specific point with coordinates (252581,592321).
      The reason I wanted to convert, was so I could use -vincenty-. But that isn't necessary?

      Comment


      • #4
        Sounds like

        Code:
         
        gen double distance = sqrt((x - 252581)^2 + (y - 592321)^2))
        to me. But I imagine you'll went to be sensible about units too. For example, if the coordinates have units metres, distances in km may be more practical.

        Comment

        Working...
        X