Wolfram Archive
Wolfram Programming Lab is a legacy product.
All the same functionality and features, including access to Programming Lab Explorations, are available with Wolfram|One.
Start programming now. »
Try it now »
(no sign-in required)

Internet Code Map

Make maps showing countries internet codes.

Run the code to get a list of countries and their internet codes:

SHOW/HIDE DETAILS

Get a natural language input box by typing +=. Type all countries into the box and run the code with +. The result is an Entity that represents all of the worlds countries:

\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "all countries", Typeset`boxes$$ = TemplateBox[{ "\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"}, \ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.709468`6.302477805217818, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)

This gives the list of all the properties known about the countries:

EntityProperties[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "all countries", Typeset`boxes$$ = TemplateBox[{"\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"},\ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.709468`6.302477805217818, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)]

Use EntityValue to get the value of a particular property for all countries:

EntityValue[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "all countries", Typeset`boxes$$ = TemplateBox[{"\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"},\ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.709468`6.302477805217818, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), EntityProperty["Country", "InternetCode"]]

If you mouse over a property like , youll see the property name, which you can use in place of the property itself:

EntityValue[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "all countries", Typeset`boxes$$ = TemplateBox[{"\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"},\ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.709468`6.302477805217818, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), "InternetCode"]

Entity gives a list of the individual country entities:

EntityValue[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "all countries", Typeset`boxes$$ = TemplateBox[{"\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"},\ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.709468`6.302477805217818, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), "Entity"]

Get both the country entities and their internet codes:

EntityValue[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{WolframAlphaClient`Private`query$$ = "all countries", WolframAlphaClient`Private`boxes$$ = TemplateBox[{ "\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], WolframAlphaClient`Private`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"},\ {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, WolframAlphaClient`Private`assumptions$$ = {}, WolframAlphaClient`Private`open$$ = {1}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 1, Dynamic[WolframAlphaClient`Private`query$$], Dynamic[WolframAlphaClient`Private`boxes$$], Dynamic[WolframAlphaClient`Private`allassumptions$$], Dynamic[WolframAlphaClient`Private`assumptions$$], Dynamic[WolframAlphaClient`Private`open$$]], StandardForm], ImageSizeCache->{85., {7., 16.}}, TrackedSymbols:>{ WolframAlphaClient`Private`query$$, WolframAlphaClient`Private`boxes$$, WolframAlphaClient`Private`allassumptions$$, WolframAlphaClient`Private`assumptions$$, WolframAlphaClient`Private`open$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{WolframAlphaClient`Private`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), {"Entity", "InternetCode"}]

HIDE DETAILS
countrycodes = EntityValue[\!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{WolframAlphaClient`Private`query$$ = "all countries", WolframAlphaClient`Private`boxes$$ = TemplateBox[{"\"all countries, dependencies, and territories\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Countries\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Countries\\\"]\"", "\"countries\""}, "EntityClass"], WolframAlphaClient`Private`allassumptions$$ = {{ "type" -> "SubCategory", "word" -> "all countries", "template" -> "Assuming ${desc1}. Use ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "Countries", "desc" -> "all countries, dependencies, and territories", "input" -> "*DPClash.CountryEC.all+countries-_*Countries-"}\ , {"name" -> "SovereignCountries", "desc" -> "all sovereign countries", "input" -> "*DPClash.CountryEC.all+countries-_*\ SovereignCountries-"}}}}, WolframAlphaClient`Private`assumptions$$ = {}, WolframAlphaClient`Private`open$$ = {1}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 1, Dynamic[WolframAlphaClient`Private`query$$], Dynamic[WolframAlphaClient`Private`boxes$$], Dynamic[WolframAlphaClient`Private`allassumptions$$], Dynamic[WolframAlphaClient`Private`assumptions$$], Dynamic[WolframAlphaClient`Private`open$$]], StandardForm], ImageSizeCache->{91., {7., 16.}}, TrackedSymbols:>{ WolframAlphaClient`Private`query$$, WolframAlphaClient`Private`boxes$$, WolframAlphaClient`Private`allassumptions$$, WolframAlphaClient`Private`assumptions$$, WolframAlphaClient`Private`open$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{WolframAlphaClient`Private`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\), {"Entity", "InternetCode"}]

Make a map of all the countries. Try different colors and sizes:

Note: run the code in the previous step first.

SHOW/HIDE DETAILS

The first country in the countrycodes list is the United States:

countrycodes[[1]]

This gives just the country entity:

countrycodes[[1, 1]]

This makes a map showing the United States country polygon in gray:

GeoGraphics[Polygon[countrycodes[[1, 1]]]]

Use EdgeForm and FaceForm to make the polygon white with a black outline (and put the contents of the graphic in a list, indicated by the curly brackets):

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[1, 1]]] }]

Make a map of all of the worlds countries:

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]] }]

Increase the size of the map to 800 pixels:

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]] }, ImageSize -> 800]

HIDE DETAILS
GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]] }, ImageSize -> 800]

Label the countries with their internet codes:

SHOW/HIDE DETAILS

Use GeoMarker to label the United States polygon with its internet code (the code is very small and red, near the center of the United States):

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[1, 1]]], GeoMarker[First[countrycodes[[1]]], Last[countrycodes[[1]]]] }, ImageSize -> 800]

Turn the GeoMarker expression into a pure function so that it can be applied to the entire list of countries. This expression does the same thing as the previous one:

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[1, 1]]], GeoMarker[First[#], Last[#]] & /@ {countrycodes[[1]]} }, ImageSize -> 800]

Make a map of all countries and their internet codes:

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]], GeoMarker[First[#], Last[#]] & /@ countrycodes }, ImageSize -> 800]

HIDE DETAILS
GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]], GeoMarker[First[#], Last[#]] & /@ countrycodes }, ImageSize -> 800]

Zoom in on part of the map. Try other regions, like southern europe or oceania:

SHOW/HIDE DETAILS

Internet codes in some parts of the map are so crowded that theyre hard to read. You can zoom in on part of the map with GeoRange. Use a natural language input box to specify a region:

GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]], GeoMarker[First[#], Last[#]] & /@ countrycodes }, ImageSize -> 800, GeoRange -> \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "carribean", Typeset`boxes$$ = TemplateBox[{"\"Caribbean\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Caribbean\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Caribbean\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "carribean", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.carribean-_*CountryClass-"}, { "name" -> "Book", "desc" -> "a book", "input" -> "*C.carribean-_*Book-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.carribean-_*Word-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.201044`5.754836109951197, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{71., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)]

HIDE DETAILS
GeoGraphics[{ EdgeForm[Black], FaceForm[White], Polygon[countrycodes[[All, 1]]], GeoMarker[First[#], Last[#]] & /@ countrycodes }, ImageSize -> 800, GeoRange -> \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "carribean", Typeset`boxes$$ = TemplateBox[{"\"Caribbean\"", RowBox[{"EntityClass", "[", RowBox[{"\"Country\"", ",", "\"Caribbean\""}], "]"}], "\"EntityClass[\\\"Country\\\", \\\"Caribbean\\\"]\"", "\"countries\""}, "EntityClass"], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "carribean", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "3", "Values" -> {{ "name" -> "CountryClass", "desc" -> "a class of countries", "input" -> "*C.carribean-_*CountryClass-"}, { "name" -> "Book", "desc" -> "a book", "input" -> "*C.carribean-_*Book-"}, { "name" -> "Word", "desc" -> "a word", "input" -> "*C.carribean-_*Word-"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.201044`5.754836109951197, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{75., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)]