ipythonでのデータ分析を行っています。(anaconda1.1.0)
私が持っているのは、緯度経度を持ったツイートの情報です。
これに基づいて、Basemap1.0.7を使用し、京都周辺の地図にデータをscatterしたいのですが、下のコードの太字部分でエラー文が出ます。
コードの下にエラー文も掲載しておきます。
どうぞ宜しくお願いします。
"パッケージのインストール"
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
%matplotlib inline
"データ読み込み"
kyoto_df = pd.read_csv('Kyoto.txt',sep='\t')
"緯度経度の代入"
lon = kyoto_df.Longitude
lat = kyoto_df.Latitude
"地図へのscatter"
plt.figure(figsize=(6, 8))
m = Basemap(projection='merc',resolution='i',
llcrnrlon=134.,urcrnrlon=137.,llcrnrlat=33,urcrnrlat=37)
m.drawcoastlines( linewidth=0.5, color='k',)
m.fillcontinents(color='#eeeeee', lake_color='#ddeeff', zorder=0)
m.drawmapboundary(fill_color='#ddeeff')
x1, y1 = m(lon,lat)
m.scatter(x1,y1)
plt.show()
”エラー文”
TypeError Traceback (most recent call last)
TypeError: expected a writable bytes-like object
During handling of the above exception, another exception occurred:
SystemError Traceback (most recent call last)
<ipython-input-190-755eb4dd5c3b> in <module>()
6 m.drawmapboundary(fill_color='#ddeeff')
7
----> 8 x1, y1 = m(lon,lat)
9 m.scatter(x1,y1)
10 plt.show()
//anaconda/lib/python3.5/site-packages/mpl_toolkits/basemap/init.py in call(self, x, y, inverse)
1146 except TypeError:
1147 y = [_dg2rad*yy for yy in y]
-> 1148 xout,yout = self.projtran(x,y,inverse=inverse)
1149 if self.celestial and inverse:
1150 try:
//anaconda/lib/python3.5/site-packages/mpl_toolkits/basemap/proj.py in call(self, *args, **kw)
284 outxy = self._proj4(xy, inverse=inverse)
285 else:
--> 286 outx,outy = self._proj4(x, y, inverse=inverse)
287 if inverse:
288 if self.projection in ['merc','mill','gall']:
//anaconda/lib/python3.5/site-packages/mpl_toolkits/basemap/pyproj.py in call(self, *args, **kw)
386 _proj.Proj._inv(self, inx, iny, radians=radians, errcheck=errcheck)
387 else:
--> 388 _proj.Proj._fwd(self, inx, iny, radians=radians, errcheck=errcheck)
389 # if inputs were lists, tuples or floats, convert back.
390 outx = _convertback(xisfloat,xislist,xistuple,inx)
_proj.pyx in _proj.Proj._fwd (src/_proj.c:1571)()
SystemError: <class 'RuntimeError'> returned a result with an error set
あなたの回答
tips
プレビュー