依存関係などは公式サイトを参照のこと。
Installation — GeoPandas 0.7.0 documentation
より。
import geopandas
#サンプルデータの取得
world = geopandas.datasets.get_path('naturalearth_lowres') #世界地図
cities = geopandas.datasets.get_path('naturalearth_cities')
#データの読み込み
df_world = geopandas.read_file(world)
df_cities = geopandas.read_file(cities)
# はじめの5行を出力
df_world.head()
"""
pop_est continent name iso_a3 gdp_md_est geometry
0 920938 Oceania Fiji FJI 8374.0 MULTIPOLYGON (((180.00000 -16.06713, 180.00000...
1 53950935 Africa Tanzania TZA 150600.0 POLYGON ((33.90371 -0.95000, 34.07262 -1.05982...
2 603253 Africa W. Sahara ESH 906.5 POLYGON ((-8.66559 27.65643, -8.66512 27.58948...
3 35623680 North America Canada CAN 1674000.0 MULTIPOLYGON (((-122.84000 49.00000, -122.9742...
4 326625791 North America United States of America USA 18560000.0 MULTIPOLYGON (((-122.84000 49.00000, -120.0000...
"""
#世界地図・都市をプロット
base = df_world.plot(color='white', edgecolor='black')
df_cities.plot(ax=base, marker='o', color='red', markersize=5)
次のような図が表示される。