我想在坐标xy=(52.52, 13.405)
上标注柏林的城市名称。我尝试过ax.annotate()
,它会产生一张奇怪的地图。也许与坐标的CRS有关?
import geopandas as gpd
import contextily as ctx
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world[(world.name=="Germany")]
world = world.to_crs(epsg=3857)
ax = world.plot(figsize=(10, 10), color='none', linewidth=1, alpha=0.5)
ax.annotate("Berlin", xy=(52.52, 13.405))
ctx.add_basemap(ax, url=ctx.providers.Stamen.Watercolor, zoom=9)
根据Annotations docpage,您的代码应如下所示:
ax.annotate("Berlin", xy=(52.52, 13.405))