巴黎:區與單車站的空間連接(spatial join)
回到巴黎的行政區與單車站資料吧。現在你要使用空間連接操作,找出每個單車站所在的行政區。
行政區與共享單車站的資料集已為你預先載入為 districts 與 stations 兩個 GeoDataFrame,且已將 GeoPandas 以 geopandas 名稱匯入。
本練習屬於課程
在 Python 中處理地理空間資料
練習說明
- 使用
geopandas.sjoin(),把每個單車站所在的行政區名稱加入stations資料集中。將結果命名為joined。 - 透過顯示前 5 列來檢查結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Join the districts and stations datasets
joined = ____
# Inspect the first five rows of the result
print(joined.____)