【发布时间】:2017-08-17 15:57:32
【问题描述】:
我有一个在 mapshaper 上看起来像这样的 shapefile:
但是当我尝试使用以下代码在 pandas 中绘制它时
police = gpd.read_file('srilanka_policestations')
police.plot()
jupyter notebook 给我一条错误消息,提示“AttributeError: 'str' object has no attribute 'type'”。
我不确定出了什么问题。我试图绘制 GeoPandas 数据集“naturalearth_cities”,它工作正常。见下文:
任何帮助都非常非常感谢。谢谢你们!
【问题讨论】:
-
嗨,
police.dtypes的输出是什么?还有type(police.loc[0,'geometry'])的输出是什么@ -
police.geometry有效吗?也尝试添加文件格式,例如'serilanka_policestations.shp'. -
谢谢你们! Bob,
police.dtypes的输出是一切(包括几何)的对象。纬度和经度都是 float64。type(police.loc[0,'geometry'])的输出是字符串。 -
Alireza,
police.geometry也不起作用,在文件名后添加“.shp”也不起作用。 :( -
type(police.loc[0,'geometry'])不应该是字符串,而应该是 shapely.geometry.Point 类型。所以读取那个文件出了点问题。你能分享shapefile吗?你也可以在github.com/geopandas/geopandas 上打开一个问题