6

I have the following code to create a Bonne projection of the Earth:

GeoGraphics[
 {
  {FaceForm[Red], EdgeForm[White], CountryData["Countries", "SchematicPolygon"]},
 },
 GeoRange -> "World",
 GeoProjection -> {"Bonne", {"Centering" -> {0, 0}, "ReferenceModel" -> 1, "StandardParallels" -> {85}}},
 GeoGridLines -> Automatic,
 GeoGridLinesStyle -> Directive[Thin, Red],
 GeoBackground -> None
]

I like the image this creates, except for the fact that the GeoGridLines appear running over the continents. Is there a way to make the GeoGridLines appear behind the land? I'm imagining something like this shirt design: https://cdn.shopify.com/s/files/1/2292/2165/products/mockup-b1b3f8b5_1024x1024.jpg?v=1504446466

sferics
  • 330
  • 1
  • 7
  • What about using {GeoStyling[FaceForm[Red], EdgeForm[White]], CountryData["Countries", "SchematicPolygon"]} as first argument of GeoGraphics? – jose Nov 17 '17 at 07:37
  • The point is that the geo grid lines will also be visible even if they are behind the polygons, because the polygons are semi-transparent by default. With GeoStyling we make them opaque, and if they are of the same color of the geo grid lines, then the latter are not visible. – jose Nov 17 '17 at 07:42
  • This solutions works pretty well for me, but there are several countries I was intending to highlight by making them a darker shade of pink/red. So with this solution, I end up the the GeoGridLines either visible on the highlighted or not-highlighted countries (depending on which color I choose the GeoGridLines to match). Do you know of a method to make the GeoGridLines invisible when passing over a country, independent of the colors involved? – sferics Nov 17 '17 at 10:19
  • You can try to always have the same color and opacity values for the world polygon and the geo grid lines. And then you use a different color and higher opacity for the countries you want to highlight. – jose Nov 17 '17 at 14:48
  • How to I control the opacity values for the world polygon and gridlines? I've tried what seems obvious to me to no effect... – sferics Nov 17 '17 at 19:07

2 Answers2

4

Probably not the best way, but one way is to make the gridlines and "map" parts in two separate GeoGraphics and combine them with Show:

lines = GeoGraphics[
  {},
  GeoRange -> "World", 
  GeoProjection -> {"Bonne", {"Centering" -> {0, 0}, 
     "ReferenceModel" -> 1, "StandardParallels" -> {85}}}, 
  GeoGridLines -> Automatic,
  GeoGridLinesStyle -> Directive[Thin, Red],
  GeoBackground -> None
  ]

Lines only

countries = CountryData["Countries", "Name"]; (*master list of countries*)
highlighted = {"China", "Algeria"}; (*list of countries to be highlighted*)
coloring[country_] := 
  Lighter[Red, If[MemberQ[highlighted, country], 0.4, 0.8]]; (*how to color them*)

countrymap = GeoGraphics[
  {
   {GeoStyling[FaceForm[coloring[#]], EdgeForm[White]], 
      CountryData[#, "SchematicPolygon"]} & /@ countries
   },
  GeoRange -> "World", 
  GeoProjection -> {"Bonne", {"Centering" -> {0, 0}, 
     "ReferenceModel" -> 1, "StandardParallels" -> {85}}}, 
  GeoBackground -> None
  ]

Countries only

Putting them together:

Show[
 Graphics @@ lines,
 Graphics @@ countrymap,
 ImageSize -> {500, Automatic} (*Just to make it a bit bigger for my own eyes*)
 ]

Final product

Not an expert at this, so please feel free to correct any mistakes/bad practices/etc. Anyway, hopefully this is (at least somewhat) helpful!

Anne
  • 1,257
  • 9
  • 13
  • 1
    Great, thank you! I tried something similar earlier, but couldn't get Show to cooperate (didn't know I had to pass the GeoGraphic output into Graphics before putting it into Show). – sferics Nov 18 '17 at 17:54
2

What about something like this? I think that if the countries have to be semi-transparent, so that some of them are highlighted, then that semi-transparency will let the geo grid lines be visible...

GeoGraphics[{GeoStyling[Red, Opacity[0.5], EdgeForm[White]], CountryData["Countries", "SchematicPolygon"], GeoStyling[Red], Polygon[Entity["Country", "Canada"]], Polygon[Entity["Country", "France"]]}, GeoRange -> "World", GeoProjection -> {"Bonne", {"Centering" -> {0, 0}, "ReferenceModel" -> 1, "StandardParallels" -> {85}}}, GeoGridLines -> Automatic, GeoGridLinesStyle -> Directive[Opacity[0.15], Red], GeoBackground -> None]

enter image description here

jose
  • 6,328
  • 1
  • 14
  • 24