GeoDataFrame を作成してジオメトリを確認する
Nashville のサービス地区がどこにあるか見てみましょう。サービス地区の shapefile へのパスは変数 shapefile_path に保存されています。
この演習はコースの一部です
Pythonで可視化する地理空間データ
演習の手順
geopandasを一般的なエイリアスgpdでインポートします。geopandasを使ってサービス地区の shapefile を読み込み、head()メソッドで先頭5行を確認します。- 1行目(行名は '0')の geometry フィールドにどのようなデータが入っているかを表示します。これには
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, '____'])