0
$\begingroup$

I'm trying to convert lat/lon coordinates into x,y coordinates onto an image of a fixed size (800x600)

I know the maximum lat/long and the minimum lat/long and I know the image size, is it possible to do extrapolation of some sort to work out where a list of points should fit on the image ?

I'm assuming that long = x and lat = y and that the points are very close so hopefully we don't need to worry about projection or curvature

I think this is simple maths but I can't seem to figure it out properly, basically I want the smallest Long to be 0 and the largest Long to be 800 and the smallest lat to be 0 and the largest lat to be 600

For example,

Min Lat 57.45827 Max Lat 57.459293 Min Lon -1.8792678 Max Lon -1.8783669

So what would the x,y coordinates of 57.459132,-1.8787674 be ?

Thanks guys

$\endgroup$

1 Answer 1

0
$\begingroup$

Simple linear interpolation should suffice for the given purpose, that is latitude $\alpha$, longitude $\beta$ maps to $$\left( 800\cdot \frac{\alpha+1.8792678}{1.8792678-1.8783669}, 600\cdot\frac{\beta-57.45827}{57.459293-57.45827}, \right). $$

$\endgroup$
2
  • $\begingroup$ Thanks hagen, why are you adding lat to the lons in this scenario, shouldn't it be the other way round? $\endgroup$
    – SamMaj
    Jan 26, 2014 at 11:32
  • $\begingroup$ If I do x = ((lon - min_lon) / (max_lon - min_lon)) * width and y = ((lat - min_lat) / (max_lat - min_lat)) * height that seems to work ok (instead of lat + im using lat -) and I'm using absolute values everywhere, does that make sense? $\endgroup$
    – SamMaj
    Jan 26, 2014 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .