開始使用免費開始

繪製 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()
編輯並執行程式碼