以多邊形與 GeoDataFrame 求交集
把土地使用資料集和行政區資料集結合後,你就能查詢特定行政區內的土地使用情形。
為此,我們先要把土地使用資料集與給定的行政區做交集。這裡一樣以「Muette」行政區作為範例。
土地使用與行政區兩個資料集已分別載入為 land_use 與 districts,而 Muette 行政區也已取出為 muette 這個 shapely 多邊形。此外,GeoPandas 和 matplotlib 也都已經匯入。
本練習屬於課程
在 Python 中處理地理空間資料
練習說明
- 計算
land_use多邊形與單一muette多邊形的交集,將結果命名為land_use_muette。 - 快速繪製這個交集結果,並傳入
edgecolor='black',以更清楚呈現不同多邊形的邊界。 - 列印
land_use_muette的前 5 列。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the land use datset and Notre-Dame district polygon
print(land_use.head())
print(type(muette))
# Calculate the intersection of the land use polygons with Notre Dame
land_use_muette = ____
# Plot the intersection
land_use_muette.____
plt.show()
# Print the first five rows of the intersection
print(land_use_muette.____)