Search code examples
pythonanacondacoordinatescoordinate-transformation

Are there functions for converting Earth coordinate systems within the standard Anaconda installer?


I specifically want to convert LLA (latitude, longitude, altitude) data into ECEF (earth-centered, earth-fixed). (LLA data is WGS84.)

Is there a function for this within the packages included with the installer for anaconda?

It would be good if this package can do more than just LLA to ECEF, such as back-conversions and other coordinate frames (e.g. ENU).


The rest of this is just clarification:

In other words, assume I have vanilla anaconda installed on a computer and can't install new packages. (Linux, 64-bit, for question completeness.)

I know the pyproj package has a function, but according to a list on the anaconda website it is not included in the installer. There are a lot of packages included with the installer and I suspect the functionality exists in one of them but searching on Stack Overflow, Google, and anaconda docs so far isn't producing answers.

Edit: Furthermore, I am aware that a function to do the one-way transform between LLA and ECEF is only around a dozen lines of code and the math is publicly available. But, I would like to find that a package has the functionality for coordinate transformations. (Three main reasons: (1) It will be useful to have the reverse transformation, and transformations to other systems. (2) I like community-supported software and won't have to type and integrate my own package. (3) I'm curious.)


Solution

  • astropy's EarthLocation

    from astropy.coordinates import EarthLocation
    longitude = -76.899626  # degrees, West (so negative), AKA 283.10037 degrees East
    latitude = 39.163002  # degrees
    x = EarthLocation.from_geodetic(longitude, latitude)
    x.geocentric
    
    Out:
    (<Quantity 1122390.43640202 m>,
     <Quantity -4823042.93548404 m>,
     <Quantity 4006364.03705792 m>)
    
    x.geocentric[0].value  # the ECEF x-value
    
    Out: 1122390.4364020245