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
add comment

2 Answers

up vote 21 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
1  
"Bosnia" is not recognized, should be "BosniaHerzegovina". –  VLC May 1 '12 at 7:55
    
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
add comment

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
add comment

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.