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
.
Diese Übung ist Teil des Kurses
Working with Geospatial Data in Python
Anleitung zur Übung
- Add a new column
'area'
with the area of each polygon to thecombined
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'
ofland_use_muette
using thegroupby()
method, and print the result.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# 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)