Drawing Maps in Mathematica

I thought I’d take a shot at drawing some maps because maps are cool, right?

We used to use CountryData[] to get the coordinates (which needed to be flipped so the image wouldn’t end up sideways) of the borders of each country to draw them. Because we are not barbarians, we will use GeoGraphics[] to draw each country.

Basic Principles

Entering the command by itself will give you an image of your location. For example:


…an image of Southern California! And you can change the styles of the maps by using the GeoBackground option. Use “StreetMapNoLabels” instead of “StreetMap” if you do not want bloated letters floating on your map.drawingmaps8.png

Fancier Techniques

GeoGraphics[] has many more sophisticated capabilities. Before I jump in, here’s a link to all of my code. I used to following variables.


We can plot several countries at once. Here’s a map with Canada, the United States, and Mexico. Color any country by using FaceForm[<replace bolded with color>]; colors do not need quotation marks. I recommend using EdgeForm[Black] because the colors tend to be light due to their opacity. You can tamper with the opacity and make them solid masses on the map, but then you will not be able to see the background as easily. For some reason, Alaska and Hawaii are excluded in the United States’ polygon data for GeoGraphics[].


We can make the map even fancier by putting the flags of each country on their designated locations. Instead of individually importing each flag, use area[“Flag”] to retrieve the image and superimpose it on the map with GeoStyling[].

If you want more demonstrations of flag maps, check out this official page from Wolfram.


It looks great, but it’s just a smidgen away from perfection. Shall we replace the flags with more appropriate images?


Muahahaha! There is no escape from current events, even on this obscure corner of the internet. This is a joke, by the way. Please do not take this seriously.

Celestial Bodies

To drown out my worries about the future of my country, let’s shift gears to something more exciting: astronomy. You can’t go wrong with outer space!

Unfortunately, Mathematica has limited functionality when it comes to drawing maps of outer space. I mean, relative to what it can do with other things. It is still possible to make awesome space maps. How about this comparison of the Moon’s Webb Crater and the Manicouagan Reservoir in Quebec? (P.S. GraphicsRow is great if you have multiple images and want to set them to the same size.)drawingmaps6

I know, the second image looks like some kind of lunar pimple more than a crater. It’s a common optical illusion, making it easy to think that the Moon has many mountains. The Manicouagan Reservoir is what’s left of a crater formed by a 5 km asteroid. The significantly more unstable weathering  conditions on Earth have clearly produced an impact on the two craters.

The Moon is the most detailed celestial body you can create maps of in Mathematica, excluding the Earth. For example, try getting a picture of Jupiter’s moon Europa:


Not looking to hot. Zooming in only yields a pixelated mess. That’s because we have very few close up images of Europa and we have not explored it too much (yet). I hope we will one day be able to send satellites there to see what lies in Europa’s vast oceans. Who knows what we’ll find there, living or not?



Analyzing the Word Frequency of Donald Trump’s and Hillary Clinton’s Speeches

We all have our stereotypes regarding the two presidential candidates of arguably the worst election in a long time: Donald Trump and Hillary Clinton. When I and many others picture Donald Trump, we think of his promise to wall dividing Mexico and the US (even though it kind of already exists in the form of chain linked fences and intense security); Hillary Clinton seems to conjure thoughts of manipulative e-mails and corporate influence. How do these two candidates compare in terms of their word choice for their speeches?

The Process: Trump’s Speech at the Republican National Convention

The following steps were taken to create a graph and a word cloud for Trump’s RNC Speech. See the notebook here for the code (locked to prevent editing)!

  1. Get the transcript (source for this speech)
  2.  Remove punctuation and unneeded words (articles, auxillary verbs, etc.), then split the words into different lists
  3. Make all of the words lowercase
  4. Tally and sort the data
  5. Generate visuals



The above steps were repeated for several speeches for a total of two per candidate.

Hillary’s DNC Speech (source):


Trump’s Youngstown, Ohio Immigration Speech (source):


Hillary’s South Carolina Speech (source)


Both candidates use the words “we” and “our” frequently to reinforce a sense of unity within their respective parties. Oddly enough, Clinton seems to use the pronoun “you” much more often than Trump. They also address each other semi-frequently, most likely because they refute each other’s arguments.

Clinton uses the words “together” and “communities” more often than Trump, who underscores “immigration” and “Terrorism.” This may have been the result of the speeches I chose. Trump also mentions ISIS frequently and focuses on the dangers immigrants may bring. This is consistent with his views of immigration. On the other hand, Clinton focuses more on bringing people together or how her campaign was supported. She probably wants to gain empathy from her audience, focusing on how well they have done as a whole.

…I don’t have much experience with text manipulation and analysis, though. My process may have several mistakes.

It isn’t very surprising that some Americans are looking for a hard-nosed leader like Donald Trump while others are looking for a candidate with somewhat safer ideas like Hillary Clinton (personally, I don’t like either of them very much but to each their own). 2016 is proving to be a disastrous year, though not quite the worst as some claim.