ComeçarComece de graça

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.

Este exercício faz parte do curso

Working with Geospatial Data in Python

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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)
Editar e executar o código