轉換為通用 CRS 並儲存到檔案
如同先前的練習所見,這兩個資料集使用不同的座標參考系統(CRS)。這一點也在本題第一個圖中顯示出來(其程式碼已在腳本中提供):兩個資料集描述的是同一個區域,理論上座標應該重疊;但實際上並沒有。
為了在本章後續進行分析,我們會把兩個資料集都轉換成相同的 CRS,並各自儲存到新檔案。為了能進行基於距離的計算,我們會將它們轉換為投影式 CRS:在地的 UTM 35 帶,其 EPSG 為 32735(https://epsg.io/32735)。
採礦據點(mining_sites)與國家公園(national_parks)兩個資料集已經載入,且已匯入 GeoPandas 和 matplotlib。
本練習屬於課程
在 Python 中處理地理空間資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the natural parks and mining site data
ax = national_parks.plot()
mining_sites.plot(ax=ax, color='red')
plt.show()
# Convert both datasets to UTM projection
mining_sites_utm = ____
national_parks_utm = ____
# Plot the converted data again
ax = national_parks_utm.plot()
mining_sites_utm.plot(ax=ax, color='red')
plt.show()