开始使用免费开始使用

检查叠加结果

现在我们已经对用地类型与行政区数据集做了叠加,便可以更方便地查看各行政区的用地情况。让我们回到示例行政区 Muette,检视该区的用地分布。

GeoPandas 和 Matplotlib 已经导入。上一练习中 overlay() 函数的结果已作为 combined 提供。

本练习是课程的一部分

在 Python 中处理地理空间数据

查看课程

练习说明

  • combined GeoDataFrame 中新增一列 'area',其值为每个多边形的面积。
  • 创建名为 land_use_muette 的子集,其中 'district_name' 等于 "Muette"。
  • 绘制 land_use_muette 的图形,并使用 'class' 列为多边形着色。
  • 使用 groupby() 方法按 'class' 计算 land_use_muette 的总面积,并打印结果。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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)
编辑并运行代码