ComeçarComece de graça

Exploring a Land Use dataset

For the following exercises, we first introduce a new dataset: a dataset about the land use of Paris (a simplified version based on the open European Urban Atlas). The land use indicates for what kind of activity a certain area is used, such as residential area or for recreation. It is a polygon dataset, with a label representing the land use class for different areas in Paris.

In this exercise, we will read the data, explore it visually, and calculate the total area of the different classes of land use in the area of Paris.

GeoPandas and matplotlib are already imported.

Este exercício faz parte do curso

Working with Geospatial Data in Python

Ver curso

Instruções do exercício

  • Read in the 'paris_land_use.shp' file and assign the result to a variable land_use.
  • Make a plot of land_use, using the 'class' column to color the polygons. We also add a legend. Note: it might take a few seconds for the plot to generate because there are a lot of polygons.
  • Add a new column 'area' with the area of each polygon.
  • Calculate the total area in km² for each 'class' using the groupby() method, and print the result.

Exercício interativo prático

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

# Import the land use dataset
land_use = geopandas.____
print(land_use.head())

# Make a plot of the land use with 'class' as the color
land_use.plot(____, legend=True, figsize=(15, 10))
plt.show()

# Add the area as a new column
land_use['area'] = ____

# Calculate the total area for each land use class
total_area = land_use.groupby(____)['area'].____() / 1000**2
print(total_area)
Editar e executar o código