【发布时间】:2021-08-11 11:09:48
【问题描述】:
我正在使用默认地图,例如:
world = geopandas.read_file(gpd.datasets.get_path('naturalearth_lowres'))
我可以使用以下 for 循环示例从另一个 GeoDataFrame(此处称为 sample_gdf)成功地将标签注释到此地图:
for idx, row in sample_gdf.iterrows():
plt.annotate(text=row['country_name'], # e.g. this column contains the names of each countries
xy=(row['longitude'], row['latitude']), # e.g. these columns are showing the coordinates of middle points of each countries
horizontalalignment='center')
This is how it looks like with epsg=4326 当我想更改地图的投影时,问题就开始了。上面变量“世界”的默认 CRS 是 epsg:4326。只要我像这样更改投影:
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world.to_crs(epsg=3035)
专注于欧洲,我的标签不再出现在正确的位置。我一直在寻找解决此问题的建议一周,但目前找不到任何解决方案。谢谢你的帮助。 And this is how it looks like with epsg=3035 标签出现在左下角。
【问题讨论】:
标签: python matplotlib coordinates geopandas annotate