PDA

View Full Version : WGS84 coordinates to a flat bitmap?


EGCC Rwy 24
2nd Jun 2003, 03:10
I'm flumoxed, but I'm sure someone here can help!!

My site (http://www.nicklocke.co.uk/Points), for those who have not yet been there, is attempting to help document the background and history of reporting point names before all the valuable anecdotal evidence is lost for ever.

For some time now, the site has offered the ability to see the approximate location of a reporting point. This is done by passing the WGS84 co-ordinates to Multimap which then does all the hard work.

I have just added the ability to show overview maps. These can show an individual point or, more importantly, the path of a route between many points.

You can see examples by clicking "Overview map" from a Point page or from a Route page.

My problem is how to convert the WGS84 co-ordinates into something that looks reasonably correct on a flat representation of the UK.

Gory details:

The bitmapped map is 310 pixels wide, by 500 tall. The SVG graphics used within the browser puts the 0,0 position in the top left. This of course is the "opposite way round" to the WGS84 co-ordinates.

So, the X and Y co-ordinates on the bitmap come from:

X = 309 - ((XXXX + 100) / 518 * 309)

Y = 499 - ((YYYY - 3000) / 519 * 499)

XXXX is the WGS84 Degrees West multiplied by 60, plus the WGS84 Minutes.

YYYY is the WGS84 Degrees North multiplied by 60, plus the WGS84 Minutes.

100 is added to counter for the fact that some of the UK is "East" and to ensure that all numbers are positive.

3000 is subtracted to counter for the fact that the Southernmost part of the UK is up from the equator.

The division by 518 or 519 was a challenge. I picked a few points at random around the extremities of the UK and noted their WGS84 co-ordinates. I then sought a number to divide by which (when multiplied back up by the number of pixels in the bitmap) seemed to give the most accurate positions. This is the bit where I really need some help!

The subtraction from 309 and 499 is simply to counter that WGS84 "increases" when going West and North, whilst the bitmap "Increases" when going South and East.

Sorry that is a long question!!

All help welcomed.

Thanks,

Nick

CBLong
2nd Jun 2003, 17:50
I'm no expert but I would suggest that you need to do some research into map projection (http://www.google.co.uk/search?q=map+projections&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search&meta=) techniques, and specifically, find out what projection your bitmap of the UK is based on.

Your conversion formulae are linear, which will only work if your bitmap is also 'linear' - ie if your bitmap is the same number of degress of longitude wide at the top and bottom. However, if that were the case for your bitmap, some distortion is inevitable - Scotland would be 'stretched' in the same way that Greenland is stretched in many atlases to appear the same size as Africa, when in fact it is many times smaller...

If your bitmap isn't linear in the sense described above, then you'll need non-linear formulae to do the mapping...

Good luck!

cbl

Zeke
2nd Jun 2003, 20:54
Nick,

Had a look at your site, not sure what projection/ellipsoid multimap are using.

WGS84 is an ellipsoid, not a projection. I believe all you would need to do is transform the co-ordinates from WGS84 ellipsoid to whatever ellipsoid multimap is using, then just plot the coordinates. (it might be something simple like the Clarke 1866)

A useful set of transformations and projections can be found in the proj4 package http://www.remotesensing.org/proj/

This is similar to what they did for the great circle mapper @ http://gc.kls2.com

EGCC Rwy 24
6th Jun 2003, 07:32
Thanks guys. Definitely some food for thought there. Much appreciated.