Get startedGet started for free

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.

This exercise is part of the course

Working with Geospatial Data in Python

View Course

Exercise instructions

  • Calculate the intersection of the land_use polygons with the single muette polygon. Call the result land_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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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.____)
Edit and Run Code