LoginSignup
6
6

More than 5 years have passed since last update.

Python matplotlib Basemapのインストール

Last updated at Posted at 2017-09-29

これまで地図のたぐいの出力はGMT (Generic Mapping Tools)で行っていましたが,Pythonでやってみたくなり,Basemapをインストールしました.その方法の紹介です.

マシン:MacBook Pro (Retina, 13-inch, Mid 2014)
OS: macOS High Sierra

インストールは以下に従って実施.

https://stackoverflow.com/questions/42299352/installing-basemap-on-mac-python

私の場合,matplotlib, numpy, geos, projはすでに入っているので,
下のサイトから,basemap-1.0.7.tar.gzを取ってくるところから始めた.

[https://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/basemap-1.0.7/[(https://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/basemap-1.0.7/)

これを解凍すると,basemap_1.0.7というディレクトリが作成される.

tar -xzv basemap-1.0.7.tar.gz

.bash_profile に以下を記載.

export GEOS_DIR=/usr/local/Cellar/geos/3.6.2/

作成されたディレクトリbasemap_1.0.7に移り python3 setup.py installを実行したところで下のエラーでストップ。

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

エラーをGoogleにつっこんだところ,下のサイトがヒット.

https://apple.stackexchange.com/questions/254380/macos-sierra-invalid-active-developer-path

http://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun/

結局,下のコマンド実行後,たくさんの警告を出しながらpython3 setup.py installが回りました.

sudo xcode-select --install

basemapのテストランを行ったところ,うまくいきました.

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

map = Basemap()
map.drawcoastlines()

fnameF='fig_basemap.png'
plt.savefig(fnameF, bbox_inches="tight", pad_inches=0.2)
plt.show()

fig_basemap.png

以 上

6
6
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
6
6