开始使用免费开始使用

绘制 Urban Residents 社区及其艺术点位

现在您已经知道大多数艺术点位位于 Urban Residents 社区。在本练习中,您将绘制该社区内的艺术点位。首先,您将从 neighborhood_art 中筛选出仅包含 urban_art 的记录,并从 neighborhoods 中筛选出 urban_polygon。然后,先将该多边形绘制为 ax,再叠加绘制艺术点位。

本练习是课程的一部分

在 Python 中可视化地理空间数据

查看课程

练习说明

  • 使用 .loc[] 访问器创建名为 urban_art 的 GeoDataFrame,只获取 "Urban Residents" 社区内的艺术点位。
  • 再次使用 .loc[] 创建名为 urban_polygon 的 GeoDataFrame,从 neighborhoods 中仅保留 "Urban Residents" 的多边形。
  • urban_polygonax 绘制,并将 color 设为 lightgreen
  • 绘制 urban_art 中的艺术点位。传入 3 个参数:设置 ax = ax 将该图层添加到 urban_polygon 上,使用 type 作为点的标签,并设置 legend = True

交互式实操练习

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

# Create urban_art from neighborhood_art where the neighborhood name is Urban Residents
urban_art = neighborhood_art.loc[neighborhood_art.name == ____]

# Get just the Urban Residents neighborhood polygon and save it as urban_polygon
urban_polygon = neighborhoods.loc[____.____ == "Urban Residents"]

# Plot the urban_polygon as ax 
ax = ____.____(color = 'lightgreen')

# Add a plot of the urban_art and show it
urban_art.plot( ax = ax, ____ = 'type', legend = True);
plt.show()
编辑并运行代码