Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Geospatial plots are great at:

  1. Showing how an area is impacted relative to other areas.

  2. Revealing which area is impacted.

  3. Illustrating a pattern in the location of something.

Geospatial plots are NOT good at:

  1. Showing how one value correlates to another. (Use a line plot for this)

  2. Emphasizing the amount of difference between one area and another.

Contiguous States Only

Let’s start off by showing the benefits of showing only the contiguous United States. Imagine that we are trying to show which states have the most electoral college votes and perhaps we want to emphasize that California has the most by a long shot.

Image
Code
Data
Comments

One the left, we see what many students show--the full 50 states.
One the right, is a much improved image showing only the 48 contiguous states.
election image

Inset Alaska & Hawaii

Eliminating two states from the drawing isn’t so great. We’d like to show Alaska and Hawaii like other maps do using an inset. This can be done, but it does get complicated rather quickly. The inset is a separate plot with separate arguments. When legends are shown, the size of the figure changes and the placement of the inset changes. I provide this code because it is educational to see and play with, but I recommend the method below this.

Modified Geometry

It becomes much easier to deal with plotting the full United States if the GeoDataFrame’s geometry is modified to put Alaska and Hawaii in the “right” spot. The only drawbacks are:

Image
Code
Data
Comments
election image

Annotated with Table Inset

The problem with the plot above is that it is very hard to see if there is any difference between Oregon and Nevada; the colors are just too close! To fix that we will annotate each state with the count of the votes printed onto the state’s location.

Image
Code
Data
Comments
election image

Finding Obvious Correlations

Is there a correlation between population and electoral votes? Does the size of a state in square miles correlate to the number of electoral votes? Geospatial provides only minimal insight; a scatter plot is better.

Image
Code
Data
Comments

One the top-left, you’ll see a plot representing Electoral Votes by state. Were we to plot a geospatial plot of Population, we’d see something virtually identical and therefore a correlation would be seen.
One the top-right, you’ll see a plot representing each state’s size in square miles.

election image

Correlations and Coefficient of Determination

In this example, we create three values (A, B, C) for each state. There is a strong correlation in the data, but the geospatial plots makes it hard to see how they relate. See if you can spot the correlations in the geospatial plots? Notice how the plots for ‘Value A’ and ‘Value C’ appear to be nearly identical, yet the details of the relationship is somewhat hidden because of the scale on the colormap. Then, the scatter & line plots make it all very apparent. Read more in the Plot Comments and Code Comments tabs.

Image
Code
Data
Plot Comments
Code Comments
Geospacial & Linear plots

Cartopy

You can make some cool plots that show the terrain of the Earth using a library called cartopy. These types of plots are good to use when you’re attempting to illustrate the location of something as it would appear on a map.

Advantages:

Disadvantages:

You can still do some geodataframe-looking plots. For example, the Hurricane Florence plot is replicated on Hurricane Katrina using this code.

Image
Code
Data
Comments

This shows a direct, “flat” Plate Carrée line between Seattle and New York as well as the curved, Geodetic line that an airplane would travel over the curved Earth, which is a more accurate reflection of reality.

election image