绘制 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_polygon以ax绘制,并将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()