GeoPandas绘图功能不工作

2024-05-29 03:11:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我在mapshaper上有一个shapefile,它看起来像这样:mapshaper

但是当我试着用下面的代码在熊猫里画出来的时候

police = gpd.read_file('srilanka_policestations')
police.plot()

jupyter笔记本给了我一条错误消息:“AttributeError:'str'object has no attribute'type'”。在

我不知道怎么了。我试着绘制GeoPandas数据集“naturalearth_cities”,效果很好。见下文:

jupyter notebook

大熊猫的地理数据框读起来不错,但它不会描绘: enter image description here

任何帮助都是非常感谢的。谢谢大家!在


Tags: 数据代码消息readplot错误笔记本jupyter
1条回答
网友
1楼 · 发布于 2024-05-29 03:11:12

geopandas GeoDataFrame中的geometry列不应包含字符串,而应包含实际的几何体对象。 如果有字符串,可以按如下方式进行转换:

import shapely.wkt
police['geometry'] = police['geometry'].apply(shapely.wkt.loads)

但是,我不得不说上面的方法是一种变通方法,就像您使用geopandas read_file来读取shapefile一样,您不应该以字符串结尾。在

相关问题 更多 >

    热门问题