開始使用免費開始

網際網路使用情形的等值區域圖

在這個練習中,你將載入一個地理空間資料檔,並建立一個簡單的等值區域圖。資料來自 ACS 表 B28011-「家戶的網際網路訂閱情形」,其中包含代表 total 家戶總數、具有 internetno_internet 存取的家戶,以及各種連網方式的欄位。

請記住,等值區域圖應該呈現比率或比例,而不是計數。載入資料後,你將使用 no_internettotal 這兩個欄位,計算沒有網際網路存取的家戶「百分比」。

本練習屬於課程

使用 Python 分析美國 Census 資料

檢視課程

練習說明

  • 以別名 gpd 匯入 geopandas
  • 使用 geopandasread_file 方法載入檔案 "states_internet.gpkg"
  • 將沒有網際網路存取的家戶百分比計算為:no_internet 的家戶數乘以 100,再除以 total
  • 透過將 column 參數設為新欄位名稱來建立此百分比的等值區域圖;將色彩映射(cmap 參數)設為 "YlGnBu"

動手互動練習

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

# Import geopandas
____

# Load geospatial data
geo_state = ____

# View GeoDataFrame columns
print(geo_state.columns)

# Calculate percent of households with no internet
geo_state["pct_no_internet"] = ____

# Create choropleth map using YlGnBu colormap
geo_state.plot(____)
plt.show()
編輯並執行程式碼