如何将 Fieldalytics API 检索到的数据加载到 GeoPandas 中?

问题描述

我从 Fieldalytics API 检索了地理边界数据:

y = getBoundary(fieldboundary)
print(y)

({'type': 'polygon','坐标': [[[-109.308557510376,51.5768561748859],[-109.285554885864,51.5768295045241],[-109.285640716553,51.562505259384],[-1509],[-105 51.5624785806018],[-109.308557510376,51.5768561748859]]]},'https://api.efcsystems.com/boundary/ff2bf689-908f-4d17-bd59-183c16758e23?format=geojson&srid=4326&api_partner_guid=...&private_key=...')

然后我尝试将其加载到 GeoPandas 中:

import geopandas
d = geopandas.read_file(y[0])

我收到以下错误消息:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-59-0eb61a9b6cc3> in <module>
      1 import geopandas
----> 2 d = geopandas.read_file(y[0])
      3 
      4 
      5 #d.plot()

~/anaconda3/lib/python3.8/site-packages/geopandas/io/file.py in _read_file(filename,bBox,mask,rows,**kwargs)
    158 
    159     with fiona_env():
--> 160         with reader(path_or_bytes,**kwargs) as features:
    161 
    162             # In a future Fiona release the crs attribute of features will

~/anaconda3/lib/python3.8/site-packages/fiona/env.py in wrapper(*args,**kwargs)
    398     def wrapper(*args,**kwargs):
    399         if local._env:
--> 400             return f(*args,**kwargs)
    401         else:
    402             if isinstance(args[0],str):

~/anaconda3/lib/python3.8/site-packages/fiona/__init__.py in open(fp,mode,driver,schema,crs,encoding,layer,vfs,enabled_drivers,crs_wkt,**kwargs)
    251             path = Parsedpath(path,archive,scheme)
    252         else:
--> 253             path = parse_path(fp)
    254 
    255         if mode in ('a','r'):

~/anaconda3/lib/python3.8/site-packages/fiona/path.py in parse_path(path)
    130         return Unparsedpath(path)
    131 
--> 132     elif path.startswith('/vsi'):
    133         return Unparsedpath(path)
    134 

AttributeError: 'dict' object has no attribute 'startswith'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)