python - 如何将 Fieldalytics API 检索的数据加载到 GeoPandas 中?
问题描述
我从 Fieldalytics API 检索地理边界数据:
y = getBoundary(fieldboundary)
print(y)
({'type': 'Polygon', 'coordinates': [[[-109.308557510376, 51.5768561748859], [-109.285554885864, 51.5768295045241], [-109.285640716553, 51.562505259384], [-109.308514595032, 51.5624785806018], [-109.308557510376, 51.5768561748859] ]]},<响应 [200]>,'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'
解决方案
推荐阅读
- react-native - 如何在 RN 中将反向 FlatList 的加载指示器保持在顶部
- angular - 为什么必须为每个惰性模块提供 HTTP_INTERCEPTORS
- android - 为什么在 Android Pie 中创建数据库时需要 close()?
- django - 如何在 Django 中访问未定义的数据库?
- c++ - 如何在多个进程中使用 Valgrind?
- php - 在 Laravel 中注册新的全局作用域
- java - Ejb不会初始化实体管理器
- amazon-web-services - Pyspark - 从 EMR 上的弹性搜索集群中读取数据
- ios - 应用程序强制退出时未收到丰富的通知
- javascript - 无法在 html 上加载存储在 aws s3 中的 csv 文件