Announcement

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

  • Converting XY coordinates into lat-long

    Hi,

    I have a data set that records the pick-up and drop-off locations of a particular item. The coordinates of these locations are in the form of XY coordinates, and I would like to calculate the distance, in kms, between the two locations using "geodist." To do the same, I have to convert the XY coordinates to Lat-Long coordinates. Appreciate any help to figure out how to convert XY coordinates to Lat-Long coordinates.

    Thank you!

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    I don't do spatial work, but spatwnat and spatgsa seem like they are commonly used. See also:

    https://www.stata.com/meeting/italy1...t12_pisati.pdf
    https://www.stata.com/statalist/arch.../msg00671.html
    https://ideas.repec.org/p/boc/dsug12/07.html


    http://www.economicas.unsa.edu.ar/ielde/download.php?file=items_upload/slides_SpatialEconomStata.pdf"

    Comment


    • #3
      Rohin Vrajesh you didn't describe the key part of the question: what is your original XY system design!? The Earth is a sphere, while XY coordinate systems are defined in planes. Any application of them for spheres is some compromise and details are key here. Best, Sergiy.

      Comment


      • #4
        Phil Bromiley - Thank you for your response.

        Sergiy Radyakin - I had imported a shapefile in Stata using shp2dta and had entered the option of gencentroids. shp2dta gave me a dta file which had the centroid coordinates of each polygon in the form shown below
        x_coord y_coord
        935997.2 191376.9
        1031085 164018.9
        1026452 254265.3
        990637.9 202960.3

        I assume this is of the XY coordinate system; however, I have little knowledge about the different coordinate systems.

        I have now used R to convert my shapefile into a dta file as I was unable to use Stata to do the same and also because I found it easier to do it in R.

        Comment


        • #5
          Originally posted by Rohin Vrajesh View Post
          I assume this is of the XY coordinate system; however, I have little knowledge about the different coordinate systems.
          Any point on the surface is described by two coordinates. I don't see from your explanation anything that would be useful to determine the correct conversion procedure.
          You don't have to be an expert in different coordinate systems (neither am I btw). But you need to go back to the source of the shapefile and inquire what was the coordinate system/projection used to produce that file.

          shp2dta will always produce variables with x_ and y_ according to the documentation:
          gencentroids(stub) requests that the coordinates of the centroids of the geographical areas of interest be computed, stored in variables x_stub and y_stub, and added to file database.dta. You must also specify the genid(newvarname) option.
          It has nothing to do with the coordinate system or projection of the digital map you are processing, but it is an assumption hardwired by the author of that command.

          Will water boil at 150 degrees?

          Finally, in all probability your mapping data is in UTM coordinates, which requires the Zone to be known in addition to Northing and Easting for correct conversion:
          https://www.engineeringtoolbox.com/u...de-d_1370.html

          Comment


          • #6
            Thank you, Sergiy! I have used R to help me generate centroid coordinates.

            To make it clear, shp2dta will generate centroid coordinates based on the type of the shapefile? Or will it always generate centroid coordinates in the UTM format? Because variables with x_ and y_ could also mean they are of the lat-long format or some other coordinate system, right?

            Comment


            • #7
              shp2dta will generate (afaik) the centroids as simple arithmetic mean of the respective coordinates of the points contained in the shapefile.

              Comment


              • #8
                Hi I am facing the same problem. Although I can tell you that my data has the following projection system:
                Code:
                PROJCS["USA_Contiguous_Albers_Equal_Area_Conic",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",37.5],UNIT["Meter",1.0]]

                Comment


                • #9
                  the proj4string is "
                  +proj=aea +lat_1=43 +lat_2=48 +lat_0=34 +lon_0=-120 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs " i want my _x _y in the coord file that is formed after shp2dta to have lat/lon.

                  Comment


                  • #10
                    Originally posted by Rohin Vrajesh View Post
                    Hi,

                    I have a data set that records the pick-up and drop-off locations of a particular item. The coordinates of these locations are in the form of XY coordinates, and I would like to calculate the distance, in kms, between the two locations using "geodist." To do the same, I have to convert the XY coordinates to Lat-Long coordinates. Appreciate any help to figure out how to convert XY coordinates to Lat-Long coordinates.

                    Thank you!
                    Same problem here Did you eventually manage to get the Lat-Long conversion?

                    Comment

                    Working...
                    X