geopandas 无法正确读取 geojson
geopandas cannot read a geojson properly
我正在尝试以下操作:
下载后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文件,上面的文件对应US Counties行,是4个中唯一读不出来的文件。报错信息是信息量不大,请问是什么原因?
如果您的错误消息看起来像 "Polygons and MultiPolygons should follow the right-hand rule",这意味着这些 GeoObjects 中的坐标顺序应该是顺时针的。
这是一个 "fix" 您的对象的在线工具,并附有简短说明:
可能是到达此页面的人的答案,我收到了同样的错误,并且由于编码问题而抛出错误。
尝试使用 utf-8 编码初始文件或尝试使用您认为应用于文件的编码打开文件。这修正了我的错误。
更多信息here
我正在尝试以下操作:
下载后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文件,上面的文件对应US Counties行,是4个中唯一读不出来的文件。报错信息是信息量不大,请问是什么原因?
如果您的错误消息看起来像 "Polygons and MultiPolygons should follow the right-hand rule",这意味着这些 GeoObjects 中的坐标顺序应该是顺时针的。
这是一个 "fix" 您的对象的在线工具,并附有简短说明:
可能是到达此页面的人的答案,我收到了同样的错误,并且由于编码问题而抛出错误。
尝试使用 utf-8 编码初始文件或尝试使用您认为应用于文件的编码打开文件。这修正了我的错误。
更多信息here