gpt4 book ai didi

python - 为 lon、lat 坐标绘制城市名称

转载 作者:太空狗 更新时间:2023-10-30 01:05:24 24 4
gpt4 key购买 nike

我想使用 Basemap 包将城市名称绘制到德国 map 上。我指定了经度和纬度值:

Cname=Form_Cities["name"].values    
Clat=Form_Cities["lat"].values
Clon=Form_Cities["lon"].values

此外,

map=Basemap(projection="lcc",resolution="l",width=1E6,height=1E6,lon_0=9.9167,lat_0=51.5167,fix_aspect=False)#Resturn just the empty "figure with no conotents on it
map.shadedrelief()
map.drawcountries(color="black",zorder=1,linewidth=1)

和:

ax.annotate(s=Cname,xy=(Clon,Clat),xycoords="axes pixels")

我想绘制城市名称,但它不工作但返回异常

ValueError: object too deep for desired array

最佳答案

你必须在一个循环中为它绘制城市名称和标记:

...
# convert your coords to map projection coords
yp,xp = map(yp,xp)
map.plot(xp, yp, 'ro', markersize=4) # plot markers
for label, xpt, ypt in zip(point_lables, xp, yp): # add annotation (city names)
plt.text(xpt+0.5, ypt+0.01, label, color='firebrick', fontsize=7)
...

关于python - 为 lon、lat 坐标绘制城市名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44735068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com