Wolfram Language

Live Version Coming Soon Check out other examples

Make a Flag Map

Make a world map where each country is colored with its flag.


code

X

how it works

This example was live-coded at the Wolfram Research booth at SXSW, March 11, 2014.

This expression makes a map with Australia indicated in black:

In[1]:=
X
Out[1]=

You can fill the country polygon with an arbitrary image, in this case, Australias flag:

In[2]:=
X
Out[2]=

Put a crisp, black border around the flag image with EdgeForm:

In[3]:=
X
Out[3]=

Apply that technique to every country in the world. Evaluating CountryData without arguments gives a list of world countries. Heres that list in abbreviated form:

In[4]:=
X
Out[4]=

This expression gives a list of {GeoStyling[...], Polygon[...]} pairs, one for each flag and country polygonjust the format required by GeoGraphics to render countries with their flags:

In[5]:=
X
Out[5]=

Use that expression within GeoGraphics to render all the countries of the world:

In[6]:=
X
Out[6]=

The country polygon for the United States doesnt include the widely separated area of Alaska. You can add Alaska explicitly by appending its polygon, rendered with the US flag:

In[7]:=
X
Out[7]=