# Hammer projection to rectangular

This might be more of a mathematical problem than a Mathematica'l one, but still, maybe you'd help me.

I want to write a function that would produce a rectangular image from an image with Hammer projection (the next step would be to map that rectangular image to a sphere, so perhaps this step might be skipped altogether, but these problems are mathematically equivalent, I suspect).

So I use this guide to write down transformation functions, and my code looks like this:

z[x_, y_] := Sqrt[1 - (x/4)^2 - (y/2)^2];
lambda[x_, y_] := 2 ArcTan[(z[x, y] x)/(2 (2 (z[x, y])^2 - 1))];
phi[y_, m_] := ArcSin[y m];
Hammertoequirect[{k_, j_}] := {lambda[k, j], phi[k, z[k, j]]};
Hammer = Import[
"http://paulbourke.net/geometry/transformationprojection/aitoff1_s.\
gif"];
equirect =
ImageForwardTransformation[Hammer, Hammertoequirect,
DataRange -> {{-1, 1}, {-1, 1}}]


And as a result, I get something utterly horrifying - like that: As might be expected, I'm not quite happy with the outcome.

I noticed that changing the DataRange changes the result, so perhaps the problem lies here (but I couldn't determine the proper value). Or maybe these gray areas at the edges of the original image should be white or transparent to get a proper result?..

Or maybe the problem is in trigonometric functions giving radians instead of degrees or in the fact that they're ambiguous in terms of sign of the argument etc., but again, I could not determine the proper form of the expressions anyway.

EDIT: As a commenter asked, I clarify: I want to get a rectangular image with a rectangular grid (so just a bunch of equidistant vertical and horizontal lines) from this image with Hammer projection grid (it's just a sample to see if the function works properly, later I'm gonna use other image instead).

If the projection is done properly, the gray areas at the edges should disappear (as I understand the procedure) - perhaps, being mapped to the very edge of the resulting rectangle. • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Oct 23, 2019 at 18:12
• Perhaps you can give a couple of images (in this post) about what you are expecting to see from this transformation? This might help others to get an idea of what you are wanting. Oct 23, 2019 at 18:14
• Thanks. I've added an edit at the end. Oct 23, 2019 at 18:46

GeoImage["World", GeoStyling[{Import["..."], "Projection" -> "Hammer"}], GeoProjection -> "Equirectangular"] 