如何修复python folium geoJSON代码中的“AttributeError:'str'对象没有属性'setdefault'”?

酋长18

如何让 folium 接受似乎导致此错误的 geoJSON 输入?

尝试制作等值线地图并遇到相同的错误,因此尝试仅使用我通过获取较大 geoJSON 文件的子集创建的 JSON 文件在基本大叶地图上进行 geoJSON 覆盖。在 Juypter Notebook 中工作。JSON 文件似乎具有正确的结构。

msp_map = folium.Map(location=[纬度,经度],zoom_start=10)

folium.GeoJson(msp_zipcode_geo, name='geojson').add_to(msp_map)

msp_map


AttributeError Traceback(最近一次调用)~/conda/lib/python3.6/site-packages/IPython/core/formatters.py in call (self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method不是 None: --> 345 return method() 346 return None 347 else:

~/conda/lib/python3.6/site-packages/folium/map.py in _repr_html_(self, **kwargs) 249 self._parent = None 250 else: --> 251 out = self._parent._repr_html_(* *kwargs) 252 返回 253

~/conda/lib/python3.6/site-packages/branca/element.py in _repr_html_(self, **kwargs) 326 327 """ --> 328 html = self.render(**kwargs) 329 html = "data:text/html;charset=utf-8;base64," + base64.b64encode(html.encode('utf8')).decode('utf8') # noqa 330

~/conda/lib/python3.6/site-packages/branca/element.py in render(self, **kwargs) 319 """渲染元素的 HTML 表示。""" 320 表示名称,孩子在 self ._children.items(): --> 321 child.render(**kwargs) 322 返回 self._template.render(this=self, kwargs=kwargs) 323

~/conda/lib/python3.6/site-packages/folium/map.py in render(self, **kwargs) 336 ''), name='map_style') 337 --> 338 super(LegacyMap, self) .render(**kwargs) 339 340

~/conda/lib/python3.6/site-packages/branca/element.py in render(self, **kwargs) 631 632 for name, element in self._children.items(): --> 633 element.render (**kwargs)

~/conda/lib/python3.6/site-packages/branca/element.py in render(self, **kwargs) 627 script = self._template.module. dict .get('script', None) 628 如果脚本不是 None: --> 629 figure.script.add_child(Element(script(self, kwargs)), 630 name=self.get_name()) 631

~/conda/lib/python3.6/site-packages/jinja2/runtime.py in call (self, *args, **kwargs) 573 (self.name, len(self.arguments))) 574 --> 575返回 self._invoke(arguments, autoescape) 576 577 def _invoke(self, arguments, autoescape):

~/conda/lib/python3.6/site-packages/jinja2/asyncsupport.py in _invoke(self, arguments, autoescape) 108 def _invoke(self, arguments, autoescape): 109 if not self._environment.is_async: -- > 110 return original_invoke(self, arguments, autoescape) 111 return async_invoke(self, arguments, autoescape) 112 return update_wrapper(_invoke, original_invoke)

~/conda/lib/python3.6/site-packages/jinja2/runtime.py in _invoke(self, arguments, autoescape) 577 def _invoke(self, arguments, autoescape): 578 """这个方法正在被异步实现。""" --> 579 rv = self._func(*arguments) 580 if autoescape: 581 rv = Markup(rv)

在宏中(l_1_this,l_1_kwargs)

~/conda/lib/python3.6/site-packages/jinja2/runtime.py in call(_Context__self, _Context__obj, *args, **kwargs) 260 args = (__self.environment,) + args 261 尝试:--> 262 return __obj(*args, **kwargs) 263 除了 StopIteration: 264 return __self.environment.undefined('值未定义,因为'

~/conda/lib/python3.6/site-packages/folium/features.py in style_data(self) 563 564 for self.data['features']: --> 565 feature.setdefault('properties', {}).setdefault('style', {}).update(self.style_function(feature)) # noqa 566 feature.setdefault('properties', {}).setdefault('highlight', {}).update( self.highlight_function(feature)) # noqa 567 return json.dumps(self.data, sort_keys=True)

AttributeError: 'str' 对象没有属性 'setdefault'

期望获得带有 geoJSON 文件中指定的县边界覆盖的地图。

酋长18

发现数据的 key_on 列中存在数据类型不匹配,其中在 geoJSON 文件中它是字符串类型,而在数据集文件中它是 int64。转换数据集文件更容易,并为 geoJSON 集中的每个多边形生成具有正确颜色范围的等值线。

还发现我作为更大的 geoJSON 文件的子集创建的 geoJSON 文件的不同之处在于,我将一些数据存储为 dict,而它应该是列表。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

python error AttributeError:'str'对象没有属性'setdefault'

来自分类Dev

如何修复AttributeError:'str'对象没有属性'_radius'?

来自分类Dev

如何修复'str'对象在我的python3脚本中没有属性'read'

来自分类Dev

Python 3.4:str:AttributeError:'str'对象没有属性'decode

来自分类Dev

Python 3.4:str:AttributeError:'str'对象没有属性'decode

来自分类Dev

Python-AttributeError:“ str”对象没有属性“ isDigit”

来自分类Dev

Python-AttributeError:“ str”对象没有属性“ append”

来自分类Dev

Python EXscript-AttributeError:“ str”对象没有属性“ connect”

来自分类Dev

Python AttributeError:“ str”对象没有属性“ DataFrame”

来自分类Dev

Python AttributeError:“ str”对象没有属性“ items”

来自分类Dev

Python AttributeError:“ str”对象没有属性“ append”

来自分类Dev

Python-AttributeError:“ str”对象没有属性“ append”

来自分类Dev

Python-AttributeError:“ str”对象没有属性“ isDigit”

来自分类Dev

AttributeError:“ str”对象没有属性“ search_nodes”-Python

来自分类Dev

AttributeError:“ str”对象没有属性“ location”-Python

来自分类Dev

Python:AttributeError:'str'对象没有属性'readlines'

来自分类Dev

AttributeError: 'str' 对象没有属性 'read' Python..

来自分类Dev

Python - AttributeError: 'str' 对象没有属性 'append' - 数学游戏

来自分类Dev

Python AttributeError:“str”对象没有“decode”属性

来自分类Dev

如何修复从PubSub读取并写入BigQuery的数据流管道中的“ AttributeError:'str'对象没有属性'items'”

来自分类Dev

'str'对象在Python3中没有属性'decode'

来自分类Dev

对于python中的以下代码,我得到了错误--AttributeError:'str'对象没有属性'next'

来自分类Dev

在DRF(django-rest-framework)中,AttributeError'str'对象没有属性'~~'如何解决?

来自分类Dev

twillio抛出AttributeError:'str'对象在Django-python中没有属性'get'

来自分类Dev

AttributeError:“ str”对象没有属性“ toLowerCase”

来自分类Dev

AttributeError:'str'对象没有属性'get'

来自分类Dev

AttributeError:“ str”对象没有属性“ items”

来自分类Dev

AttributeError:'str'对象没有属性'sleep'

来自分类Dev

AttributeError:“ str”对象没有属性“ maketrans”

Related 相关文章

  1. 1

    python error AttributeError:'str'对象没有属性'setdefault'

  2. 2

    如何修复AttributeError:'str'对象没有属性'_radius'?

  3. 3

    如何修复'str'对象在我的python3脚本中没有属性'read'

  4. 4

    Python 3.4:str:AttributeError:'str'对象没有属性'decode

  5. 5

    Python 3.4:str:AttributeError:'str'对象没有属性'decode

  6. 6

    Python-AttributeError:“ str”对象没有属性“ isDigit”

  7. 7

    Python-AttributeError:“ str”对象没有属性“ append”

  8. 8

    Python EXscript-AttributeError:“ str”对象没有属性“ connect”

  9. 9

    Python AttributeError:“ str”对象没有属性“ DataFrame”

  10. 10

    Python AttributeError:“ str”对象没有属性“ items”

  11. 11

    Python AttributeError:“ str”对象没有属性“ append”

  12. 12

    Python-AttributeError:“ str”对象没有属性“ append”

  13. 13

    Python-AttributeError:“ str”对象没有属性“ isDigit”

  14. 14

    AttributeError:“ str”对象没有属性“ search_nodes”-Python

  15. 15

    AttributeError:“ str”对象没有属性“ location”-Python

  16. 16

    Python:AttributeError:'str'对象没有属性'readlines'

  17. 17

    AttributeError: 'str' 对象没有属性 'read' Python..

  18. 18

    Python - AttributeError: 'str' 对象没有属性 'append' - 数学游戏

  19. 19

    Python AttributeError:“str”对象没有“decode”属性

  20. 20

    如何修复从PubSub读取并写入BigQuery的数据流管道中的“ AttributeError:'str'对象没有属性'items'”

  21. 21

    'str'对象在Python3中没有属性'decode'

  22. 22

    对于python中的以下代码,我得到了错误--AttributeError:'str'对象没有属性'next'

  23. 23

    在DRF(django-rest-framework)中,AttributeError'str'对象没有属性'~~'如何解决?

  24. 24

    twillio抛出AttributeError:'str'对象在Django-python中没有属性'get'

  25. 25

    AttributeError:“ str”对象没有属性“ toLowerCase”

  26. 26

    AttributeError:'str'对象没有属性'get'

  27. 27

    AttributeError:“ str”对象没有属性“ items”

  28. 28

    AttributeError:'str'对象没有属性'sleep'

  29. 29

    AttributeError:“ str”对象没有属性“ maketrans”

热门标签

归档