如何解决使用ArcGIS API for Python绘制地图时,引起循环参考的原因是什么?
在documentation(适用于Python的ArcGIS API)之后,我正在尝试从启用了空间的数据框中绘制坐标。也许我对循环引用的理解已经关闭,但是我看不到对象将如何引用自身。
import pandas as pd
from arcgis.gis import GIS
## importing geocoded data from pickle
prop_sdf = pd.read_pickle("./recent_geocoded.pkl")
prop_sdf = pd.DataFrame.spatial.from_xy(prop_sdf,'lat','long')
prop_sdf.head()
这就是我得到的数据帧的样子:
unique_id lat long
0 43432884 41.701011 -70.019244
2 43400770 41.641784 -70.366659
3 43425636 41.701954 -70.146602
4 43427274 41.720506 -70.021849
5 43427818 41.649288 -70.490767
我能够渲染交互式地图
m1 = GIS().map("United States")
m1.zoom = 4
m1.center = [39,-98]
但是在绘制时遇到错误:
prop_sdf.spatial.plot(map_widget=m1)
m1
踪迹:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-30-d48a9f223ff4> in <module>
----> 1 prop_sdf.spatial.plot(map_widget=m1)
2 m1
~\anaconda3\lib\site-packages\arcgis\features\geo\_accessor.py in plot(self,map_widget,**kwargs)
2002 self._data.columns = [c.replace(" ","_") for c in self._data.columns]
2003 # plot and be merry
-> 2004 _plot_map_widget(map_widget)
2005 self._data.columns = orig_col
2006 return True
~\anaconda3\lib\site-packages\arcgis\features\geo\_accessor.py in _plot_map_widget(mp_wdgt)
1984 colors=kwargs.pop('cmap',None) or kwargs.pop('colors',None) or kwargs.pop('pallette','jet'),1985 alpha=kwargs.pop('alpha',1),-> 1986 **kwargs)
1987
1988 # small helper to address zoom level
~\anaconda3\lib\site-packages\arcgis\features\geo\_viz\mapping.py in plot(df,name,renderer_type,symbol_type,symbol_style,col,colors,alpha,**kwargs)
191 fc.layer['layerDeFinition']['drawingInfo']['renderer'] = renderer
192 if map_exists:
--> 193 map_widget.add_layer(fc,options={'title':name})
194 else:
195 map_widget.add_layer(fc,options={'title':name})
~\anaconda3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py in add_layer(self,item,options)
1051 _is_geoenabled(item):
1052 item = item.spatial.to_feature_collection()
-> 1053 self._add_layer_to_widget(item,options)
1054
1055 def _add_layer_to_webmap(self,options):
~\anaconda3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py in _add_layer_to_widget(self,options)
1091 # (i.e.,do what was done for ImageryLayer for all major Layers)
1092 # 'No type' layer just means that we'll figure it out at JS time
-> 1093 _lyr = _make_jsonable_dict(item._lyr_json)
1094 if ('type' in _lyr and \
1095 _lyr['type'] == 'MapImageLayer') and \
~\anaconda3\lib\site-packages\arcgis\widgets\_mapview\_mapview.py in _make_jsonable_dict(obj)
60 will later be used to delete all values with this value"""
61 return flag
---> 62 dict_ = json.loads(json.dumps(obj,default=default_func))
63 return { k:v for k,v in dict_.items() if v != flag }
64
~\anaconda3\lib\json\__init__.py in dumps(obj,skipkeys,ensure_ascii,check_circular,allow_nan,cls,indent,separators,default,sort_keys,**kw)
236 check_circular=check_circular,allow_nan=allow_nan,indent=indent,237 separators=separators,default=default,sort_keys=sort_keys,--> 238 **kw).encode(obj)
239
240
~\anaconda3\lib\json\encoder.py in encode(self,o)
197 # exceptions aren't as detailed. The list call should be roughly
198 # equivalent to the PySequence_Fast that ''.join() would do.
--> 199 chunks = self.iterencode(o,_one_shot=True)
200 if not isinstance(chunks,(list,tuple)):
201 chunks = list(chunks)
~\anaconda3\lib\json\encoder.py in iterencode(self,o,_one_shot)
255 self.key_separator,self.item_separator,self.sort_keys,256 self.skipkeys,_one_shot)
--> 257 return _iterencode(o,0)
258
259 def _make_iterencode(markers,_default,_encoder,_indent,_floatstr,ValueError: Circular reference detected
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。