Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在matplotib和geopandas中注释xy点_Python_Python 3.x_Matplotlib_Gis_Geopandas - Fatal编程技术网

Python 在matplotib和geopandas中注释xy点

Python 在matplotib和geopandas中注释xy点,python,python-3.x,matplotlib,gis,geopandas,Python,Python 3.x,Matplotlib,Gis,Geopandas,我正在尝试使用Geopandas注释地图上的一些点,但我的问题与matplotlib更相关 我已经为xy创建了一列坐标点,但在尝试多种方法时,会收到以下警告 ValueError: ('not enough values to unpack (expected 2, got 1)', 'occurred at index 0') 我要注释的文本是id号(pod_id_位置),我只想在它们各自的点旁边(或上)绘制这些编号,以便在地图上绘制时可以看到哪个id对应于哪个点。我试图使用lambda

我正在尝试使用Geopandas注释地图上的一些点,但我的问题与matplotlib更相关

我已经为xy创建了一列坐标点,但在尝试多种方法时,会收到以下警告

ValueError: ('not enough values to unpack (expected 2, got 1)', 'occurred at index 0')

我要注释的文本是id号(pod_id_位置),我只想在它们各自的点旁边(或上)绘制这些编号,以便在地图上绘制时可以看到哪个id对应于哪个点。我试图使用lambda apply将这些值从一列映射到另一列中的坐标。我看不出哪里出了问题,同样的错误是使用for循环。感谢您的指点,我的数据和代码如下:

    pod_id_location geometry    Zone
0   1245    POINT (-22993.152 6728924.970)  non-ULEZ
7940    2245    POINT (-13406.652 6714132.654)  ULEZ
13934   3245    POINT (-16958.244 6720147.066)  non-ULEZ
25068   5245    POINT (-20791.698 6699568.057)  non-ULEZ
32551   6245    POINT (-40049.413 6704610.464)  non-ULEZ
... ... ... ...
849223  742451  POINT (-12923.302 6720129.538)  non-ULEZ
849547  832450  POINT (-6445.287 6717978.299)   non-ULEZ
851190  872450  POINT (-4064.943 6697346.893)   non-ULEZ
852852  892450  POINT (6744.514 6713063.033)    non-ULEZ
853523  982450  POINT (-958.349 6706975.535)    non-ULEZ

通过将lambda函数更改为以下内容,我成功地解决了该问题:

gdf_2.apply(lambda x: ax.annotate(s=x.pod_id_location, xy=x.loc['geometry'].coords[0]), axis=1)


因为shapley对象的第一个元素是坐标。由于某种原因,我的情节现在打印的是微小的。。。但这是我需要解决的问题

从昨天开始我一直在寻找这个问题,终于找到了这个问题和答案。多谢各位
gdf_2.apply(lambda x: ax.annotate(s=x.pod_id_location, xy=x.loc['geometry'].coords[0]), axis=1)