pythonlocationlatitude-longitudegoogle-earthsatellite

Convert x,y position to LLA in decimal degree


I am trying to convert a pixel position (x,y) on a map tile to Longitude, Latitude, Altitude (LLA) format (decimal degree). I have a piece of a map from google earth over Spain at night time. I have the LLA for all four corners and I want know the LLA location of a pixel at x:657, y: 81

Spain_Night

How do I know which map projection to use? Is there an easy way to calculate the LLA position for each pixel in this image? and can the same method be applied to different map tiles from google earth?

I am trying to develop this conversion either on python or matlab

Thanks


Solution

  • I am sure there is a much better solution, I am pretty new to python, but this is how I would start looking at approaching it if I were looking for a longitude and latitude at a given pixel position. *My apologies if that is not exactly what you are looking for, I may have misunderstood.

    # image size in pixels
    img_size = [807, 152]
    
    # Pixel position
    px_pos = (225, 35)
    
    def calc_lla(top_r_lat, top_r_long, bottom_l_lat, bottom_l_long, map_size, pos):
    
      # Taking the latitude of the upper right corner and bottom left, subtracting them, dividing the difference by map size in pixels, then multiplying that with the position given
      lat = top_r_lat - (((top_r_lat - bottom_l_lat) / map_size[0]) * pos[0])
    
      # same as above for longitude
      long = top_r_long - (((top_r_long - bottom_l_long) / map_size[1]) * pos[1])
      return (lat, long)
    
    
    print(calc_lla(44.372321, -7.904955, 40.801188, -3.088944, img_size, px_pos))
    
    # Returns (43.37665194795539, -6.79600509868421)