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.
Diese Übung ist Teil des Kurses
Working with Geospatial Data in Python
Anleitung zur Übung
- 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
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# 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.____)