Question

I have x,y data coming in from a [coordinates1] database (GIS - but this could be any database). I have my application with it's own coordinate system, referencing THE SAME MAP.

I have established that a linear relationship exists between coordinates1 (x,y) and coordinates2(x,y) as I have subtracted two different coordinates1 and coordinates2 (dividing x1 with x2 and y1 with y2) and in all cases I get them both showing 0.724 or 0.141 or 0.825 respectively i.e. coordinates1 + coordinates2.

What I now need to figure out - or you help - is that if coordinates1(100000,200000) and coordinates2(0.125,0.255) how do I calculate coordinates2(x,y) from the data in coordinates1(x,y)?

Was it helpful?

Solution

For the sake of clarity, I'm going to call coordinates in your base (xn, yn), and coordinates in your target (un, vn).

Now, if we assume:

  1. The origins of the two coordinate systems are the same.
  2. The orientation of the two coordinate systems are the same (i.e. one is not rotated with respect to the other).

In this case you only need one set of points {(x1, y1), (u1, v1)} to determine the location of (un, vn):

  • un = u1/x1 * xn
  • vn = v1/y1 * yn

Note: we must have x1 ≠ 0, y1 ≠ 0


On the other hand, if the two coordinate systems have different origins (but they are still not rotated with respect to one another), we will need two sets of points {(x1, y1), (u1, v1)} and {(x2, y2), (u2, v2)}:

  • un = (u2 - u1)/(x2 - x1) * (xn - x1) + u1
  • vn = (v2 - v1)/(y2 - y1) * (yn - y1) + v1

Note: we must have x1x2, y1y2


Now, if the two coordinate systems are rotated with respect to one another, you need (I believe) one more set of matching coordinates. But it doesn't sound like you need that (unless one of your maps has north pointing in a direction other than straight up), so I'm not going to work out the math now. :)

OTHER TIPS

To do the conversion, you need to know the coordinates of one point O in your two coordinates systems .

Let's suppose O has coordinates x1O,y1O in coordinate system 1, and x2O,y2O in coordinate system 2.

Then a point with coordinates x1,y1 in system 1, and x2,y2 in system 2 will satisfy:

(x1O - x1) = Kx * (x2O - x2)
(y1O - y1) = Ky * (y2O - y2)

where Kx and Ky are the scale factor. If you know the coordinates of an other point M in both systems, than you will have Kx and Ky with

Kx = (x1O - x1M) / (x2O - x2M)
Ky = (y1O - y1M) / (y2O - y2M)

Then, you just need to apply the first relationship to go from one system to another system, with

x1 = x1O - Kx * (x2O - x2)
y1 = y10 - Ky * (y2O - y2)

or

x2 = x2O - (x1O - x1) / Kx
y2 = y2O - (y1O - y1) / Ky

Do you also need the code ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top