TransWikia.com

GeoGraphics Day/Night way off

Mathematica Asked on January 14, 2021

I’ve been struggling to figure out the correct GeoGraphics options to get the desired results. Here’s what I have so far and the results that I’m getting:

   g = Show[
   Graphics[{}, ImageSize -> {Automatic, 1000}],
   GeoGraphics[GeoRange -> "World", GeoCenter -> {60, 0}, 
    GeoProjection -> "Orthographic", 
    GeoGridLines -> Quantity[20, "AngularDegrees"], 
    GeoGridLinesStyle -> {AbsoluteThickness[1], 
      AbsoluteThickness[1]},
    GeoBackground -> {"CountryBorders", "Land" -> LightGray, 
      "Ocean" -> White, "Border" -> Black}
    ],
   GeoGraphics[{GeoStyling[Opacity[0.1]], 
     EdgeForm[{Black, AbsoluteThickness[7]}], 
     DayHemisphere[{2020, 01, 01, 15}]}]
   ];
   Magnify[g, 0.5]

And here’s the result:

orthographically projected map

Rather than being the expected hemisphere, it’s a wacky shape.

One Answer

I think what's causing the issue is that the hemisphere polygon boundary is being folded over itself. One such workaround is to triangulate this polygon.

We can convert DayHemisphere to Polygon by going under the hood with GeoGraphics`GeoEvaluate, and then to a fine union of triangles with DiscretizeRegion.

tris = DiscretizeRegion[
  GeoGraphics`GeoEvaluate[DayHemisphere[{2020, 01, 01, 15}]], 
  MaxCellMeasure -> 10];

MeshCellCount[tris]
{4168, 11275, 7108}
p = MeshPrimitives[tris, 2][[All, 1]];

gp = Apply[{Mod[#1, 180, -90], Mod[#2, 360, -180]} &, Reverse[p, {3}], {2}];

GeoGraphics[{GeoStyling[{Red, Opacity[0.5]}],  
  {EdgeForm[], Polygon[GeoPosition[gp]]}, 
  {AbsoluteThickness[7], DayNightTerminator[{2020, 01, 01, 15}]}}, 
  GeoRange -> "World", GeoProjection -> "Orthographic", GeoCenter -> {60, 0}, 
  GeoGridLines -> Quantity[20, "AngularDegrees"], 
  GeoGridLinesStyle -> {AbsoluteThickness[.5], AbsoluteThickness[.5]},
  GeoBackground -> {"CountryBorders", "Land" -> LightGray, "Ocean" -> White, 
   "Border" -> Directive[Black, AbsoluteThickness[.15]]}]

Correct answer by Chip Hurst on January 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP