I'm working on a project involving data from the Lunar reconnaissance orbiter. Datasets are usually 5064 pixels wide and 52224 pixels in height, and the general (2 significant figures) coordinates for latitude and longitude are given in the metadata for the center of the observation as well as each of the corners. A typical observation with those coordinates might look something like this:
Let's say I wanted to get the pixel values of the center of the prominent crater in this image that I know the Latitude and Longitude of. In this case, the coordinates of that crater are -11.80 South and 33.14 East. How could I do that?
A few notes, some of these images are inverted, as the orbiter might have south as up. The observations are also usually not straight, as the orbiter does not have a perfect polar orbit, though occasionally the side latitudes or top/bottom longitudes match up.
Here is some python code I have tried to use so far (assuming that x values increase as you go eastwards and y values increase as you go southwards):
(using Numpy as np)
eps_x_left = Lower_left_longitude - Upper_left_longitude
eps_x_right = Lower_right_longitude - Upper_right_longitude
eps_y_up = Upper_right_latitude - Upper_left_latitude
eps_y_low = Lower_right_latitude - Lower_left_latitude
# handle case where x's or y's are equal: means slope is infinite
if eps_x_left != 0:
mx = (Upper_left_latitude - Lower_left_latitude)/eps_x_left
else:
mx = np.infty
if eps_y_up != 0:
my = (Upper_right_longitude - Upper_left_longitude)/eps_y_up
else:
my = np.infty
x_prime = (y_tar - Upper_left_latitude)/mx + Upper_left_longitude
y_prime = (x_tar - Upper_left_longitude)/my + Upper_left_latitude
r_x = abs(Upper_right_longitude + eps_x_right
- Upper_left_longitude + eps_x_left)/img_size[0]
r_y = abs(Upper_left_latitude + eps_y_up
- Lower_left_latitude + eps_y_low)/img_size[1]
p_x = int(abs(x_tar - x_prime)/r_x)
p_y = int(abs(y_tar - y_prime)/r_y)
This code seems to work fine, but if I have two observations of the same crater that are at different rotations, the location I get is not always the same.