Geoplotlib AttributeError:"bytes"对象没有属性"编码"



我正在使用geoplotlib并试图显示具有已知纬度和经度值的地图为float。但是我一直得到如下所示的错误。

min_lat = 51
max_lat = 58
min_lon = 0
max_lon = -6
latitudes  = [entry  for entry in latitudes]
longitudes = [entry for entry in longitude]
bbox = BoundingBox(north=max_lat, south=min_lat, west=min_lon, east=max_lon)
geoplotlib.set_bbox(bbox)
geo_data_for_plotting = {"lat": latitudes,
"lon": longitudes}
geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
geoplotlib.inline()

错误
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:UsersOLUMOR~1AppDataLocalTemp/ipykernel_1288/1765196798.py in <module>
15 
16 geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
---> 17 geoplotlib.inline()
~anaconda3envsitopslibsite-packagesgeoplotlib__init__.py in inline(width)
69     if os.path.isfile(fname + '.png'):
70         with open(fname + '.png', 'rb') as fin:
---> 71             base64 = urllib.parse.quote(fin.read().encode("base64"))
72 
73         image_html = "<img style='width: %dpx; margin: 0px; float: left; border: 1px solid black;' src='data:image/png;base64,%s' />" % (width, base64)
AttributeError: 'bytes' object has no attribute 'encode'

制作完字典后,添加以下行将其转换为DataAccessObject:

geo_data_for_plotting = geoplotlib.utils.DataAccessObject(geo_data_for_plotting)

最新更新