2
$\begingroup$

I can center an orthographic projection of the earth over New Zealand with

GeoGraphics[GeoProjection -> {"Orthographic", "Centering" -> {-41, 174}}]

enter image description here

However, centering fails for the Mollweide projection:

GeoGraphics[GeoProjection -> {"Mollweide", "Centering" -> {-41, 174}}]

enter image description here

How can I generate a Mollweide projection of the earth centered over New Zealand?

$\endgroup$
2
  • 2
    $\begingroup$ GeoGraphics[{} , GeoProjection -> {"Mollweide" , "Centering" -> GeoPosition[Entity["Country", "NewZealand"]] } , GeoGridLines -> Automatic , GeoRange -> "World" , GeoCenter -> Entity["Country", "NewZealand"] , ImageSize -> Large ] ? $\endgroup$
    – Syed
    Aug 27, 2022 at 18:52
  • $\begingroup$ @Syed no, what you suggest is a perspective from a point above the equator at New Zealand's longitude. You have only centered the longitude but not the latitude. I want to look at the globe from a point hovering directly above New Zealand, so that New Zealand appears at the center of the map (horizontally and vertically). $\endgroup$
    – Roman
    Aug 27, 2022 at 19:27

1 Answer 1

1
$\begingroup$

Not the most elegant solution, but we can

  • Create an Image of earth in the equirectangular projection.
  • Transform the pixels of the image so that New Zealand is at the center.
  • Use GeoStyling[{"GeoImage", _}] to project this image onto the map.

Here's the rotation transform, which is unnecessarily brute force: geoposition -> spherical coordinates -> Cartesian coordinates -> rotation -> spherical coordinates -> geoposition.

tfunc = FullSimplify[
  RotationTransform[α °, {-Sin[β °], Cos[β °], 0}], {α, β} ∈ Reals];

res = Simplify[{π/2 - #1, #2}/Degree & @@ 
    Rest[CoordinateTransform["Cartesian" -> "Spherical", 
      tfunc[CoordinateTransform["Spherical" -> "Cartesian", 
        {1, (90 - lat) °, lon °}]]]], {α, β, lat, lon} ∈ Reals];

With[{gp = {Mod[#1 - β, 360, -180], #2} & @@ Reverse[res]},
  geoRotate = Compile[
    {{α, _Real}, {β, _Real}, {lat, _Real}, {lon, _Real}}, 
    gp,
    CompilationTarget -> "C", 
    RuntimeOptions -> "Speed"
  ]
];

Image of earth:

im = GeoImage["World", "StreetMapNoLabels", 
   GeoProjection -> "Equirectangular", ImageSize -> 1024];

Location to center around:

loc = Entity["Country", "NewZealand"];

{x, y} = QuantityMagnitude[LatitudeLongitude[loc], "AngularDegrees"];

Transform to place New Zealand in the center in the equirectangular projection:

im2 = ImageForwardTransformation[im, geoRotate[x, y, #[[2]], #[[1]]] &, 
  DataRange -> {{-180, 180}, {-90, 90}}]

enter image description here

Mollweide projection:

GeoGraphics["World", GeoProjection -> "Mollweide", 
  GeoGridLines -> Automatic, ImageSize -> 1024, 
  GeoBackground -> GeoStyling[{"Image", im2, "Projection" -> "Mollweide"}]
]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.