ポリゴン上に点を重ねて描く - パート2
いつものライブラリは pd、plt、gpd として、鶏のデータセットは chickens、サービス地区は service_district として読み込まれています。サービス地区と鶏の許可データを一緒にプロットして、可視化からどんなことが見えるか確かめましょう。
この演習はコースの一部です
Pythonで可視化する地理空間データ
演習の手順
- まずはサービス地区の GeoDataFrame をプロットします。凡例の色には
name列を使います。 - 次に、鶏のデータの緯度・経度を散布図として重ねます。マーカーの色は
'black'、縁取りは'white'に指定します。 - プロットにタイトル 'Nashville Chicken Permits' を付け、x 軸ラベルを 'longitude'、y 軸ラベルを 'latitude' にします。
- グリッド線を追加し、プロットを表示します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Plot the service district shapefile
service_district.plot(column=____, legend=True)
# Add the chicken locations
plt.scatter(x=____, y=____, c=____, edgecolor = 'white')
# Add labels and title
plt.____('Nashville Chicken Permits')
plt.xlabel(____)
plt.ylabel(____)
# Add grid lines and show the plot
plt.____()
plt.____()