geoplotlib attributeError:' bytes'对象没有属性' encode'

发布于 2025-01-24 15:52:09 字数 1359 浏览 0 评论 0原文

我正在与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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彻夜缠绵 2025-01-31 15:52:09

制作dict后,添加以下行以将其转换为dataAccessObject

geo_data_for_plotting = geoplotlib.utils.DataAccessObject(geo_data_for_plotting)

After you make the dict, add the following line to transform it into a DataAccessObject:

geo_data_for_plotting = geoplotlib.utils.DataAccessObject(geo_data_for_plotting)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文