Exercise

Visualizing the population density

Let's get back to the districts dataset. In a previous exercise we visualized the districts with a uniform column. But often we want to show the spatial variation of a variable, and color the polygons accordingly.

In this exercise we will visualize the spatial variation of the population density within the center of Paris. For this, we will first calculate the population density by dividing the population number with the area, and add it as a new column to the dataframe.

The districts dataset is already loaded as districts, GeoPandas has been imported as geopandas and matplotlib.pyplot as plt.

Instructions

100 XP
  • Print the first rows of the districts dataset. Do you see the 'population' column?
  • Inspect the area of the districts's geometries.
  • Add a column 'population_density' representing the number of inhabitants per squared kilometer (Note: The area is given in squared meter, so you will need to multiply the result with 10**6).
  • Plot the districts using the 'population_density' to color the polygons.