Getting geographical coordinates from pixel positions relative to known places on a map

85 Views Asked by At

I have a screenshot from a map of my hometown and I want to use it for a project of mine.

For that I need the geographical coordinates of the point in the top left corner. I could just look it up on Google Maps, but I'd prefer to have a analytical solution since I may have to use another map soon.

The situation is the following: I have two points on the map of which I know the exact geographical coordinates and their pixel positons (e.g. $52.12345$ N, $11.1234$ O and $324 \times 1532$). I need a way to determine the geographical positions of the top left corner (=top left pixel) so I can further process it in python, but can't figure it out on my own.

I appreciate any help given!

1

There are 1 best solutions below

2
On

The first step is to project the latitude and longitude to rectangular North and East coordinates. Note that the screen coordinates are recognized as South and East coordinates. If that second fundamental can be resolved then the North or South coordinates can be translated by addition of a constant to convert from one rectangular benchmark to another. Similarly the East coordinates can be translated by addition of a constant.

For example here is a fixed spherical projection:

24N and 34E translates longitude, for the purpose of projection calculation, to 24N and 1W .

Then 25N and 36E translates longitude to 25N and 1E .

Zero longitude is straddled for the purpose of calculation and essentially making a calculation zone.

Next the North coordinate for 24N is 1852 meters * 60 * 24 or 2666880.0 . Then the East coordinate for 1W is 1852 * 60 * 1 * Cos(24) or -101513.17 with the negative value for West.

Continuing, the North coordinate for 25N is 1852 * 60 * 25 or 2778000.0 . Then the East coordinate for 1E is 1852 * 60 * 1 * Cos(25) or 100708.92 .

Finally, as a check, the direction and distance from the first set of rectangular coordinates to the second set is 61_12.686 degrees_minutes and 230741 meters. Then the direction and distance between UTM coordinates for the actual beginning latitudes and longitudes is 60_30.863 degrees_minutes and 231027 meters.

The more exact result projects the latitudes and longitudes to UTM coordinates using transverse mercator formulas and that without translated longitudes. However, use of UTM projections can use translated longitudes to straddle the center of a UTM zone and produce a more accurate projection for a small project. So the direction and distance between 24N 32E and 25N 34E is 61_20.651 degrees_minutes and 230910 meters and that's when straddling the center of a UTM zone with translated longitudes.

Another available projection for small projects is an ellipsoidal Local-Tangent-Plane-from-ECEF. But with the z-coordinate not used then that system is referenced as an ellipsoidal orthographic projection. This projection is less complicated than transverse mercator but only accurate to about 90 km from center. But also, this projection does not depend on being close to the equator for accuracy on the zone edges.

But I'll go ahead and calculate the latitude and longitude of the upper left corner based on my example:

On a screen of 1024 x 768 take the latitude and longitude of [24N , 34E] to be screen coordinates of [100 , 100]. Recognize those screen coordinates as North and East coordinates of [668 , 100]. Subtract the screen North coordinate from the rectangular North coordinate calculated for 24N latitude and the North coordinate translation is 2666212. Then subtract the screen East coordinate from the rectangular East coordinate calculated for 34E longitude and the East coordinate translation is -101613.17.

Now the upper left corner of the screen has North and East coordinates of [768 , 0]. Add the North coordinate translation to 768 for 2666980.0 . Add the East coordinate translation to 0 for -100613.17 .

Convert the North coordinate of the upper left screen of 2666980 to latitude with:

1852 * 60 * Lat = 2666980

Lat = 24_0.054 degrees_minutes

Convert the East coordinate of the upper left screen of -101613.17 to untranslated longitude with:

1852 * 60 * Lon * Cos(24_0.054) = -101613.17

Untranslated Lon = -01_0.060 degrees_minutes

Add the longitude translation of 35 degrees for Lon = 33_59.940 degrees_minutes .

A short cut might be obvious but by developing a North coordinate translation and a East coordinate translation then the system is prepared to work with additional points.