Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider the following list of countries which I would like to highlight on a world map:

MyCountries={"Germany","Hungary","Mexico","Austria","Bosnia","Turkey","SouthKorea","China"};

From the documentation center (Country Data > Applications > Application 5), I know that

Graphics[{If[CountryData[#, "AntarcticNations"], Orange, LightBrown], 
    CountryData[#, "SchematicPolygon"]} & /@ CountryData[]]

works for all antarctic nations. I replaced "AntarcticNations" by MyCountries but it does not seem to work.

share|improve this question

3 Answers 3

up vote 23 down vote accepted

In the example code, CountryData[#, "AntarcticNations"] is a built in predicate that returns True or False. You need something similar for your countries. Perhaps,

myCountries={
  "Germany","Hungary","Mexico","Austria",
  "Bosnia","Turkey","SouthKorea","China"};
Graphics[{If[MemberQ[myCountries,#],Orange,LightBrown],
  CountryData[#,"SchematicPolygon"]}& /@ CountryData[]]

enter image description here

share|improve this answer
2  
"Bosnia" is not recognized, should be "BosniaHerzegovina". –  VLC May 1 '12 at 7:55
1  
I'd like to add that CountryData[#, {"Polygon", "Mollweide"}] allows to set the projection used for the map. –  Karsten W. Jul 22 '12 at 12:40

Mathematica 10 introduced new ways to highlight countries on the world map. Examples follow below. There are lots of more examples in the documentation which showcase alternative stylings.

myCountries = Map[
   Entity["Country", #] &,
   {"Germany", "Hungary", "Mexico", "Austria", "Turkey", "SouthKorea", "China"}
   ];

GeoListPlot[myCountries, ImageSize -> 800]

Map 1

GeoListPlot[myCountries, GeoBackground -> "ReliefMap", ImageSize -> 800]

Map 2

GeoRegionValuePlot[MapThread[Rule, {myCountries, RandomReal[10, Length@myCountries]}]]

Map 3

GeoGraphics[
 {EdgeForm[Black], FaceForm[Orange], Polygon /@ myCountries},
 ImageSize -> 800
 ]

enter image description here

share|improve this answer

Alternate approach:

Graphics[{
  {Orange, CountryData[#, "SchematicPolygon"] & /@ MyCountries}, 
  {LightBrown, 
      CountryData[#, "SchematicPolygon"] & /@ Complement[CountryData[], MyCountries]}
  }]

which draws all of "your countries" in one color, and then the rest of the world in another.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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