geoplotlib attributeError:' bytes'对象没有属性' encode'
我正在与Geoplotlib合作,并试图显示具有已知纬度和纵向值的地图。但是我不断收到错误,如下所示。
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:\Users\OLUMOR~1\AppData\Local\Temp/ipykernel_1288/1765196798.py in <module>
15
16 geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
---> 17 geoplotlib.inline()
~\anaconda3\envs\itops\lib\site-packages\geoplotlib\__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'
I am working with geoplotlib and trying to show a map with known latitudes and longitudes values as float. But i keep getting the error as seen below.
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()
error is
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\Users\OLUMOR~1\AppData\Local\Temp/ipykernel_1288/1765196798.py in <module>
15
16 geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
---> 17 geoplotlib.inline()
~\anaconda3\envs\itops\lib\site-packages\geoplotlib\__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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
制作dict后,添加以下行以将其转换为
dataAccessObject
:After you make the dict, add the following line to transform it into a
DataAccessObject
: