Skip to content

Latest commit

 

History

History
265 lines (161 loc) · 5.46 KB

lecture10.md

File metadata and controls

265 lines (161 loc) · 5.46 KB
title layout include_vega
Lecture 10
lecture
true

Data Visualization

## Matthew Turk ## Spring 2018 ## Lecture 10

Warm-Up Activity

  1. What is the visualization trying to show?
  2. What are its methods?
  3. What are the strengths / weaknesses?

https://vimeo.com/239582792


Last Time

  • Choosing an Engine
  • More bqplot
  • Markdown

Today

  • Maps
    • Projections
    • Coordinate Systems
    • Plotting with CartoPy
  • Assignment
  • Idyll

Maps

The Earth is a sphere.

(Fun question: to what degree is it a sphere?)

Have you ever wrapped a piece of paper around a ball?


Projections

To map from one system to another, we must "project" from the original sphere to the flat object we are observing.

What are some things we could preserve during such a projection?


Projections: Common Preservations

Typically, one or more of these will be preserved, or at least, the distortion will be minimized:

  • Area
  • Shape (Conformal)
  • Distance

There are other properties that can be preserved, as well. Typically, maps will be a "compromise" between preserving different properties.

What happens when we preserve one property over another?


Mercator is a "conformal" projection. What is wrong with this?


Projections: Distortions

We can characterize distortions in a projection by examining how a known shape appears on them. The Tissot Ellipse of Distortion is a method of showing this by drawing circles of a fixed radius and examining their elliptical distortion.


What do you notice?













Discussion

What happens when we make a map that minimizes one region and maximizes another?


Maps: Coordinate Systems

Once we have our system of transformation, we need to have a method of representing positions.

Three common baseline methods:

  • Spherical coordinates
  • Latitude and Longitude
  • Degrees, minutes, seconds

Take care with:

  • Zero points
  • North/South, East/West
  • Ranges

Intro to cartopy

CartoPy is a toolkit that builds on matplotlib to create fast, easy map representations.

We will be relying on three key concepts:

  • Axes projections (similar to our polar projections)
  • Coordinate representations
  • Shapes

Using these, we will be able to build out many visualizations.


CartoPy: Projections

We start out by constructing an axes in CartoPy that uses a given projection:

import cartopy
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection=cartopy.crs.Mollweide())
ax.coastlines()

What does this do?


CartoPy: Coordinate Reference Systems

Transforming from a spherical reference system to a flat reference system is the job of the projection; transforming from one discretization of a sphere to another is the job of the coordinate system.

We can utilize Coordinate Reference Systems to describe the input coordinate system and the rasterization system are described.

For example, there are several different ways to draw "straight" lines. We can do both PlateCarree and Geodetic.

c_lat, c_lon = 40.1164, -88.2434
a_lat, a_lon = -18.8792, 47.5079
fig = plt.figure()
ax = fig.add_subplot(111, projection = cartopy.crs.PlateCarree())
ax.gridlines()
ax.coastlines()
ax.set_global()
ax.plot([c_lon, a_lon], [c_lat, a_lat], transform = cartopy.crs.PlateCarree())
ax.plot([c_lon, a_lon], [c_lat, a_lat], transform = cartopy.crs.Geodetic())



CartoPy: Examples

Let's now set up CartoPy to plot some of the data we saw last week, in the transportable array.


Other Map Viz

  • Google Maps & Earth
  • WorldWide Telescope
  • CesiumJS

Assignment

Your assignment is posted in the nbgrader instance. You have a week and a half, but it's easy.


Idyll

Idyll is a reactive markup language for visualization and narrative documents.

idyll-lang.org

We will create a name explorer.