繪製 Urban Residents 社區與藝術作品
你現在知道大多數藝術作品都位在 Urban Residents 社區。這個練習要你在該社區中繪製藝術作品的圖。你會先從 neighborhood_art 篩出 urban_art,再從 neighborhoods 篩出 urban_polygon。接著,先把多邊形畫成 ax,再把藝術作品加到圖上。
本練習屬於課程
在 Python 視覺化地理空間資料
練習說明
- 使用
.loc[]建立名為urban_art的 GeoDataFrame,只取"Urban Residents"社區中的藝術作品。 - 再用
.loc[]從neighborhoods建立名為urban_polygon的 GeoDataFrame,只保留"Urban Residents"的多邊形。 - 將
urban_polygon繪製為ax,並將color設為lightgreen。 - 繪製
urban_art中的藝術作品。請傳入三個參數:設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()