3

On a map that I know the coordinates (lat/lng) of three corners (or any three non aligned points) I have coordinates (lat/lng) of a few points that are located on the map.

What I want is the relative coordinates (x/y relative to top left corner) of the points to the map.

I'm also interested in the other conversion (x/y to lat/lng).

My maps are pretty small (less than 10 km x 10 km) do I need to use a projection system or can I just assume that my surface is perfectly flat and use a linear conversion ?

EDIT : I don't know (and I have no way to know) which projection my background map uses. I just know 3 georeferenced points.

A solution is to use a linear conversion :

If my three points are A (xA,yA), B (xB, yB) , C (xC,yC) and the point I want to position X (x, y).

I can compute a and b as AX = aAB + bAC in the lat/lng referential then

x = xA + a * (xB-xA) + b * (xC - xA) y = yA + a * (yB-yA) + b * (yC - yA)

But it looks like I'm missing something?

Related question : How to map a latitude/longitude to a distorted map?

luxcem
  • 1,807
  • 22
  • 37

3 Answers3

0

It depends on the map however a linear transformation is simple. You can also use a Kavrayskiy transformation. I also found the reverse:Get latitude and longitude from X and Y coordinates. Here is a question about a mercantor projection:Convert lat/lon to pixel coordinate?.

Community
  • 1
  • 1
Micromega
  • 12,486
  • 7
  • 35
  • 72
  • I'm wondering, do I need to use a projection (I don't know what projection my map use, I just know 3 georeferenced points). What problems should I expect with a simple linear conversion. – luxcem Mar 10 '14 at 17:11
0

If you'd like to get accurate conversion, you need to use the local projection of the country / region, these coordinates fall into. And you can easily identify that by looking up one of the coordinates in google maps (assuming the whole set of coordinates doesn't span a huge area), and that will tell you in which country / region, the coordinates are. From there you can lookup the local projection system used in that country. And unless the purpose here is to come up with a conversion algorithm/utility on your own, you can make use of some libraries which implement all the needed computation to reproject coordinates from and to many projection systems:

proj4, jmpl, which is a partial java port of proj4

b2Wc0EKKOvLPn
  • 2,054
  • 13
  • 15
0

You are right, you are missing something. Your formula (which I haven't examined in depth) looks linear, and therefore appears to apply only to affine transformations. A map is not (in general) an affine transformation from (lat,lon) to (x,y).

If things were that easy, you could determine the transformation even if you knew the coordinates of the points (0,0), (10,0) and (5,10) of a 10x10 square - but you cannot, because the x direction could conserve distances or longitudes or something else (when latitude, i.e., y changes), and you cannot tell these cases apart. You will have to use additional information.

Walter Tross
  • 12,237
  • 2
  • 40
  • 64