I wish Mathematica had more advanced vector-graphics and layering; this is so simple in a drawing program. A good solution would preserve everything as vector with no rasterized textures, but I don't think it can be done in a general way. -- edit I didn't notice that the Flag data is already raster. I guess Texture makes the most sense in that case.
–
Mr.Wizard♦Feb 4 '12 at 23:45

You may find ImagePad useful if you want small flags inside country borders
–
SzabolcsFeb 5 '12 at 1:00

1

One caveat: This texture-based approach leads to a graphic that cannot be exported to PDF (on Macs, at least). This seems worth mentioning since you specifically asked for a method preserving the vector character of the borders. Just in case anyone encounters this, a workaround for this problem is to export to svg first, and then use Inkscape to convert to PDF.
–
JensFeb 5 '12 at 19:24

For coastal countries with a lot of islands, CountryData[tag,"Polygon"] gives something of the form Polygon[{island1, island2, island3,...}], where island1 and the like is another list of latitudes and longitudes.

The case is simpler for inland countries. CountryData[tag,"Polygon"] gives Polygon[{island1}], where island1 is simply the mainland, and is itself a list of latitudes and longitudes.

The function accepts as argument a polygon of an island of a country, which is of the form Polygon[{{x1,y1},{x2,y2},...}}]. We obtain the list of coordinates with First[].

We apply transpose to the list of coordinates {{x1,y1},{x2,y2},...}}, so that we group all the x's together, and y's together: {{x1, x2, x3, ...}, {y1, y2, y3, ...}}. We apply to it Rescale[], so that x's and y's are both rescaled from 0 to 1 separately. Then apply transpose to group them back into {{x1,y1},{x2,y2},...}}, where x and y is now in [0,1].

Then we can overlay the flag onto a country. Let's use Hong Kong (though not a country, but it has many islands) as an example. The important thing is to treat each island of a country one by one.

What do you think of this piece of code Graphics[{EdgeForm[Black],{Texture[CountryData[#1,"Flag"]],Polygon[#,VertexText‌​ureCoordinates->countryRescale1[Polygon[#]]]&/@First[CountryData[#1,"FullPolygon"‌​]]}&/@CountryData[]},ImageSize->200] as compared to the one using Table[]?
–
JonasJun 8 '14 at 7:12

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.