0

I have an SVG map (called "external map" hereafter) representing a portion of the globe ; along with a map of the globe ("background map") in its entirety. I would like to be able to detect what projection the external map uses (my final aim being to superimpose the two maps). For the moment I only consider the Mercator, equirectangular and orthographic projections.

I developed a code that shows the two maps (external on the left, background on the right) and allows the user to drag/zoom on the background map and choose one of these projections (link). If I manually fiddle with these properties I conclude that the external map was probably created using the Mercator projection ; but how could I have found this result programmatically ? I thought about the following algorithm :

  1. Ask the user to choose, say, 5 points that he would geolocalize on both maps.
  2. Calculate the (pixel-based) distances between each of the 5 points on the external map.
  3. For each projection :
    • Center and scale the background map using the coordinates of the 5 points that the user located on the background map.
    • Calculate the pixel-based distances between the 5 points on the background map. Compare them with the distances calculated on step 2. The projection with the smallest distance differences is then considered to be the one that was used to create the external map.

This algorithm raises several questions :

  • On step 3, how can I calculate the center of the map using the located points ? The projections are often distorted, so using proportionality to find it doesn't seem right.
  • For the same reasons, I don't know how I could determine the scale (zoom) to apply on the background map.

This algorithm seems quite natural but the issues I raise make it look impossible to implement. Are there other (better) algorithms that could help me determine this projection ? If I can find it manually there must be a way to find it programmatically !

I use d3 for the map rendering if it helps.

Bruno Pérel
  • 575
  • 6
  • 21
  • Perhaps you can do it with a neural network. The input would be a set of 20 values (i.e. x,y pairs of the 5 points in **background** and x,y pairs of the same 5 points in **external** map). The output would be 4 or more values. The first 3 values are **rotationX**, **rotationY** and **scale** of the projection. The 4th, 5th, (etc) values would correspond to the projection (eg **[1,0,0,0]** for mercator, [0,1,0,0] for equirectangular, etc). You would train the neural network with thousands of examples that you can produce automatically by randomly choosing sets of 5 points and projecting them. – meetamit Dec 30 '14 at 03:37
  • Wow, that sounds quite heavy. So except from machine learning there is no way to do that ? – Bruno Pérel Jan 02 '15 at 08:52
  • I don't know enough math to conclusively say that there is no way to do it following the approach you outline. But it does seem very difficult, specifically because the large number of variables — including the projection type, its 3-axis rotations, centering, scaling, and (in some cases) other projection-specific params. There also doesn't seem to be much useful or promising info about it [on the web](https://www.google.com/search?q=auto+detecting+map+projection&oq=auto+detecting+map+projection&aqs=chrome..69i57.7876j0j1&sourceid=chrome&es_sm=91&ie=UTF-8#safe=off&q=identify+map+projection). – meetamit Jan 02 '15 at 09:39
  • I don't even know that the neural network approach would work, but it seems like a super interesting project — if you're able to dedicate a couple of weeks to it. The Stanford Machine Learning course provide all the info needed in order to attempt it (in fact, neural networks are fully covered in the first one-third of that course. – meetamit Jan 02 '15 at 09:47

0 Answers0