【发布时间】:2019-05-22 06:36:38
【问题描述】:
我正在尝试以下方法:
下载后http://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_050_00_20m.json
In [2]: import geopandas
In [3]: geopandas.read_file('./gz_2010_us_050_00_20m.json')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-83a1d4a0fc1f> in <module>
----> 1 geopandas.read_file('./gz_2010_us_050_00_20m.json')
~/miniconda3/envs/ml3/lib/python3.6/site-packages/geopandas/io/file.py in read_file(filename, **kwargs)
24 else:
25 f_filt = f
---> 26 gdf = GeoDataFrame.from_features(f_filt, crs=crs)
27
28 # re-order with column order from metadata, with geometry last
~/miniconda3/envs/ml3/lib/python3.6/site-packages/geopandas/geodataframe.py in from_features(cls, features, crs)
207
208 rows = []
--> 209 for f in features_lst:
210 if hasattr(f, "__geo_interface__"):
211 f = f.__geo_interface__
fiona/ogrext.pyx in fiona.ogrext.Iterator.__next__()
fiona/ogrext.pyx in fiona.ogrext.FeatureBuilder.build()
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
在页面http://eric.clst.org/tech/usgeojson/的20m列下有4个geojson文件,上面的文件对应于美国县行,是4个中唯一无法读出的文件。错误信息不是很丰富,请问是什么原因?
【问题讨论】:
-
例如 QGIS 可以读取文件吗?
-
是的,QGIS可以打开文件
-
错误信息是否看起来像“多边形和多多边形应该遵循右手法则”?因为如果是这样,则意味着您应该对 Polygons/MultiPolygons 中的坐标进行排序。
-
@oriash,我不确定这是否是问题所在。但是如何按 lat 或 lng 对坐标进行排序?
-
顺时针。 mapster.me/right-hand-rule-geojson-fixer 应该可以工作。