Intersecting a GeoDataFrame with a Polygon
Combining the land use dataset and the districts dataset, we can now investigate what the land use is in a certain district.
For that, we first need to determine the intersection of the land use dataset with a given district. Let's take again the Muette district as example case.
The land use and districts datasets have already been imported as land_use
and districts
, and the Muette district has been extracted into the muette
shapely polygon. Further, GeoPandas and matplotlib are imported.
Cet exercice fait partie du cours
Working with Geospatial Data in Python
Instructions
- Calculate the intersection of the
land_use
polygons with the singlemuette
polygon. Call the resultland_use_muette
. - Make a quick plot of this intersection, and pass
edgecolor='black'
to more clearly see the boundaries of the different polygons. - Print the first five rows of
land_use_muette
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Print the land use datset and Notre-Dame district polygon
print(land_use.head())
print(type(muette))
# Calculate the intersection of the land use polygons with Notre Dame
land_use_muette = ____
# Plot the intersection
land_use_muette.____
plt.show()
# Print the first five rows of the intersection
print(land_use_muette.____)