Math Cartography: Convert map projections

Arthur Dent

Absolutely Mental
Donator
Joined
Feb 8, 2008
Messages
336
Reaction score
1
Points
18
Location
Dresden
Website
wasa.pottyland.de
Hi Everyone,

for a project I'm working on, I need to convert a fictional planet map that is only available in a Wagner VII projection (aka Hammer-Wagner projection) to an [ame="http://en.wikipedia.org/wiki/Equirectangular_projection"]Equirectangular (flat) projection[/ame], so I can use it in Orbiter.

I've stumbled upon a page with interesting formulas, including the defintion formula of the Wagner VII projection. But I don't know how to use them, as I am neither good at math nor at programming.

There is a tool called GeoCart, but it comes with a 240 $ price tag.

I've tried to reshape the map manually, but the results are not that satisfactory. And I'd need to do that about once a month (that's how often the source map changes).

Is there a simple and cheap way to convert this map? Or maps in general between two projection types. Bonus if it works not only with rasterized graphics but also with vector graphics.

Any help is highly appreciated. This problem is troubling me for a while now.


Source files:
Source map SVG (old)
Source map PNG (recent)
Converted map with watermarked DEMO version of GeoCart

PS: As soon as I get it to work, the author will grant me access to the complete sources of that map.
 
Last edited:
Given the link in your first post to the transformation formulae, this should be a straightforward task. Orbiter's maps are simple cylindrical projections, i.e. the x-coordinates of the map are a linear function of longitude, the y-coordinates a linear function of latitude. If your target map is of size nx x ny, you can encode the transformation as follows (in pseudo-code):

Code:
for y=[0:ny-1]
  long = y/ny*2pi-pi
  for x=[0:nx-1]
    lat = x/nx*pi-pi/2
    wx,wy = wagner(long,lat)
    img[x,y] = wimg[wx,wy]
  end
end

where wagner() is the function that returns the Wagner coordinates for a given (longitude,latitude) coordinate pair, as detailed on the web page. img is your target image, and wimg is assumed to be the source image in Wagner format.

In practice, wx and wy won't be integers, so you probably need to implement an interpolation scheme to extract the correct value from your source image (you can start with nearest neighbour, but bilinear or bicubic interpolation will give better results).
 
So basically you treat individual horizontal and vertical pixels of the image as longitudinal and latitudinal lines?
Learned something new. :)
 
Back
Top