Aligning images with latitude and longitude details.

Say you have an image with some stuff you know the latitude and longitude for, here is a way to figure out all four sides of the image in lat/long.  The one restriction is the image must have straight sides that are aligned north/south east/west.  Lat/long must be in decimal.

For Longitude pick 2 points far apart in x (east/west).

Point 1 = X1 in pixels and Long1 in degrees.
Point 2 = X2 in pixels and Long2 in degrees.

The size of the image in x is X3

Now, figure out the change in pixels vs the change in degrees:

 ABS(X1-X2) = DXP
 ABS(Long1-Long2) = DXL

DXL / DXP = DPX

DPX is degrees per pixel in x.

Now to get the sides pick one point (X1), calculate the distance to each side in pixels, and use DPX to calculate the distance in degrees.

Long1 + X1*DPX = Side1
Long1 - (X3-X1)*DPX = Side2

For the other sides it is the same just use Y and latitude:

For Latitude pick 2 points far apart in y (north/south).

Point 3 = Y1 in pixels and Lat1 in degrees.
Point 4 = Y2 in pixels and Lat2 in degrees.

The size of the image in x is Y3

Now, figure out the change in pixels vs the change in degrees:

 ABS(Y1-Y2) = DYP
 ABS(Lat1-Lat2) = DYL

DYL / DYP = DPY

DPY is degrees per pixel in y.

Now to get the sides pick one point (Y1), calculate the distance to each side in pixels, and use DPY to calculate the distance in degrees.

Lat1 + Y1*DPY = Side3
Lat1 - (Y3-Y1)*DPY = Side4

Clear as mud?

Back to the alignment page.

Marty Schultz
9/24/99