I have X and Y coordinates from a resized image that has its origins from a Sentinel 2B photo. The original photo is 109.681 by 110.334 km. The re-dimensioned file is 370 by 369. I also know the latitude and longitude coordinates from the upper right and left corner, center and lower right and left corner.
So by multiplying a desired X and Y pixel by 300m(how much 1 pixel equals to) and applying the Euclidean distance formula I can find out how far said pixel is from my reference point(I'm using the upper right corner as reference.) My first attempt at translating the Cartesian coordinates to lat and long went as following:
def pixel_meter():
global x_meter
global y_meter
x_pixel = int(input('Which X pixel? '))
y_pixel = int(input('Which Y pixel? '))
x_meter = (x_pixel * PIXEL_METER) * -1
y_meter = (y_pixel * PIXEL_METER) * -1
def conversion():
dLat = y_meter / EARTH_RADIUS
dLon = x_meter / (EARTH_RADIUS * np.cos(np.pi * LAT_REFERENTIAL / 180))
lat_final = LAT_REFERENTIAL + dLat * 180 / np.pi
lon_final = LON_REFERENTIAL + dLon * 180 / np.pi
print(lat_final, lon_final)
That got me close, but when I checked it on a map online it was still off by some kilometers to what would make sense by judging from the pixels displayed by the resized picture.
Then after searching some more I found about the Vincenty's formula and how more precise it is. With pygeodesy I tried this:
from pygeodesy.ellipsoidalVincenty import LatLon
p = LatLon(-18.088506124573, -44.907758947306) #Reference point
d = p.destination(85854, 224.47) # Distance to my desired X, Y coordinates and bearing from center.
print (d.lon, d.lat)
The distance is calculated using Euclidean's distance.
The result is still off, and I'm certain it is because of the bearing. I don't know, and found no way to know what would be the bearing of my points of interest(more than 4 thousand X,Y points).
Is there any way to calculate the bearing just from the information I have?
That is, latitude and longitude from center, upper corners, lower corners and original covered area. I'm open to any possible methods, really.
Also, if it's not possible to calculate the bearings then is there any other way to make this translation between coordinates more precise?