Search code examples
pythonutmgeographic-distance

Get lat lon for a pos when only dx dy is known from an other point


The problem I have is getting the latitude and longitude for a position when I know one origin position and the offset to the other point (in meter)

I want to use following function (or any other function that gives me a correct lat2 and lon2):

import geographiclib
geographiclib.geodesic.Geodesic.Direct(self, lat1, lon1, azi1, s12)

I have some example data:

lon1 = 11.62113333
lat1 = 55.9862

dx = -51659.25 #meter
dy = -33702.33 #meter

This is the result that I'm hoping to achieve:

azi1 = -120.95109978727244
s12 = 61691.57175978693         
lat2 = 55.69834 
lon2 = 10.77969

When I use a UTM2latlon converter I'm getting a position that is way off.. I think that the coordinate system that is used to calculate dx and dy is ESPG:5596.

Since the distances is great and the distance have taken into account for the earthsPythagoras Theorem isn't applicable to calculate s12 and azi1. Any suggestions on functions etc.?


Solution

  • Thanks for the try!

    Unfortunately I worked with some old algorithm so the "correct answer" was a more trivial function.

    def melat(lat):
        return  degrees( log ( tan ( radians( lat / 2 + 45 ) ) ))
    
    def latit(mlt):
        return ( degrees(atan ( exp ( radians(mlt) ) )) - 45 ) * 2
    
    def XY2LatLong(x, y):
        EQUATOR_MINUTE_LENGTH = 1851.8518519
        GeoPoint = namedtuple('GeoPoint', ('lat', 'lon'))
        Point = namedtuple('Point', ('x', 'y'))
        base = GeoPoint(55.98619572, 11.62113936)
        factor = cos( radians(base.lat) ) * EQUATOR_MINUTE_LENGTH * 60.
        return GeoPoint(
            latit(melat(base.lat) + y / factor),
            base.lon + x / factor)