開始使用免費開始

建立 GeoDataFrame 並檢視幾何資料

來看看 Nashville 的服務區在哪裡。服務區的 shapefile 路徑已經存到變數 shapefile_path

本練習屬於課程

在 Python 視覺化地理空間資料

檢視課程

練習說明

  • 以常見別名 gpd 匯入 geopandas
  • 使用 geopandas 讀取服務區的 shapefile,並用 head() 方法查看前 5 列。
  • 列印第一列(列名為 '0')的幾何欄位,看看其中包含的資料。你可以將 service_district.loc[0, 'geometry'] 傳給 print() 函式來完成。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import geopandas
import ____ as ____ 

# Read in the services district shapefile and look at the first few rows.
service_district = gpd.____(shapefile_path)
print(service_district.____())

# Print the contents of the service districts geometry in the first row
print(service_district.loc[0, '____'])
編輯並執行程式碼