Get startedGet started for free

Inspecting the overlay result

Now that we created the overlay of the land use and districts datasets, we can more easily inspect the land use for the different districts. Let's get back to the example district of Muette, and inspect the land use of that district.

GeoPandas and Matplotlib are already imported. The result of the overlay() function from the previous exercises is available as combined.

This exercise is part of the course

Working with Geospatial Data in Python

View Course

Exercise instructions

  • Add a new column 'area' with the area of each polygon to the combined GeoDataFrame.
  • Create a subset called land_use_muette where the 'district_name' is equal to "Muette".
  • Make a plot of land_use_muette, using the 'class' column to color the polygons.
  • Calculate the total area for each 'class' of land_use_muette using the groupby() method, and print the result.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Print the first rows of the overlay result
print(combined.head())

# Add the area as a column
____ = ____

# Take a subset for the Muette district
land_use_muette = combined[____]

# Visualize the land use of the Muette district
land_use_muette.____(____)
plt.show()

# Calculate the total area for each land use class
print(land_use_muette.____(____)['area'].____() / 1000**2)
Edit and Run Code