1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Python】Cartopyを使って日本地図を作成

Last updated at Posted at 2021-10-30

概要

Cartopyを使って日本地図や世界地図を描く

完成図(ソース上のcartopy.png)はこちら。
cartopy.png

環境

Python: 3.9
pip: 21.3.1
Cartopy: 0.19.0
matplotlib: 3.4.1

インストール

Cartopyやmatplotlibをインストールしていない場合は、pipでインストールしてください。
condaでも問題ないと思います(未確認)。

bash
pip install cartopy
bash
pip install matplotlib

実際に描いてみた

cartopy.py
import cartopy.crs as ccrs
import cartopy.feature as cfea
import matplotlib.pyplot as plt
  
# 描画サイズ指定
plt.figure(figsize=(10, 10))
ax = plt.axes(projection=ccrs.PlateCarree())
  
# ラベル表示
ax.gridlines(draw_labels=True)
  
# 描画位置(Lon, Lat)指定
ax.set_extent((120.0, 160.0, 30.0, 50.0), ccrs.PlateCarree())
  
# 海洋と陸地の色を指定
ax.add_feature(cfea.OCEAN,color='#00FFFF')
ax.add_feature(cfea.LAND,color='#32CD32')
  
plt.title('japan', fontsize=15)
  
# 画像保存
plt.savefig('cartopy.png')

詳細

GitHubにもソース等を置いています。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?