1
$\begingroup$

Recently, I wanted to create a map showing the flags of the countries. From the documentation, I found and used the following:

flags = EntityValue["Africa", , {"Entity", "Flag"}];

GeoGraphics[{EdgeForm[
   Black], {GeoStyling[{"Image", #2}], 
     Tooltip[Polygon[#1], CommonName[#1]]} & @@@ flags}, 
 GeoBackground -> "StreetMapNoLabels"]

Then I found :

# Show the disembodied shapes of countries in South America:
Row[Show[CountryData[#, "Shape"], ImageSize -> {50, 50}] & /@ CountryData["SouthAmerica"]]

Now, I am trying to add the flags and maybe the countries names as captions.

The result should look like this: enter image description here

$\endgroup$
2
  • $\begingroup$ Your code doesn't work. $\endgroup$ – Kuba Jan 15 '16 at 12:16
  • 3
    $\begingroup$ Duplicate. Answer also available in documentation for Texture $\endgroup$ – rhermans Jan 15 '16 at 12:17
1
$\begingroup$

Code:

   With[{vc = 
         Transpose[
          Rescale /@ Transpose[First[CountryData[#, "Coordinates"]]]]}, 
       Show[CountryData[#, "Shape"], 
         ImageSize -> {{100}, {100}}] /. {RGBColor[__] :> 
          Texture[ImageReflect[Image[CountryData[#, "Flag"]], 
            Top -> Right]], 
         Polygon[a_] :> 
          Polygon[First[a], VertexTextureCoordinates -> vc]}] & /@ 
     CountryData["SouthAmerica"]

Reference:

Texture

Mathematica graphics

$\endgroup$

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