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).
This exercise is part of the course
Working with Geospatial Data in Python
Exercise instructions
- Make a plot using the
'n_trees'
variable to color the polygons. Make sure to also display a legend using thelegend
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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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()