ComenzarEmpieza gratis

Equal interval choropleth

In the last exercise, we created a map of the tree density. Now we know more about choropleths, we will explore this visualisation in more detail.

First, let's visualize the effect of just using the number of trees versus the number of trees normalized by the area of the district (the tree density). Second, we will create an equal interval version of this map instead of using a continuous color scale. This classification algorithm will split the value space in equal bins and assign a color to each.

The district_trees GeoDataFrame, the final result of the previous exercise is already loaded. It includes the variable n_trees_per_area, measuring tree density by district (note the variable has been multiplied by 10,000).

Este ejercicio forma parte del curso

Working with Geospatial Data in Python

Ver curso

Instrucciones del ejercicio

  • Make a plot using the 'n_trees' variable to color the polygons. Make sure to also display a legend using the legend keyword.
  • Repeat the same using the 'n_trees_per_area' variable. Do you see the difference?
  • Generate a choropleth with the 'n_trees_per_area' variable using an equal interval classification scheme. Again, make sure to add a legend.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Print the first rows of the tree density dataset
print(districts_trees.head())

# Make a choropleth of the number of trees 
districts_trees.plot(____, ____)
plt.show()

# Make a choropleth of the number of trees per area
districts_trees.plot(____, ____)
plt.show()

# Make a choropleth of the number of trees 
districts_trees.plot(____, ____, ____)
plt.show()
Editar y ejecutar código